Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show / hide entire group of fields #63

Open
K15Lmk98 opened this issue Oct 19, 2018 · 1 comment
Open

Show / hide entire group of fields #63

K15Lmk98 opened this issue Oct 19, 2018 · 1 comment

Comments

@K15Lmk98
Copy link

This is an automatic translation

Hello,

maybe I did not understand the examples, but I can not condition (show / hide) an entire group of fields, directly from the creation from the main field of the group.

Instead it works if I apply the code to every single field in the group.

The conditional field is outside the group.

Code:

DOES NOT WORK
$cmb_cr_frontpage_image_id = $cmb_cr_frontpage_image->add_field( array( 'id' => PREFIXCMB2 . 'frontpage_image_group', 'type' => 'group', 'name' => __( 'Elenco immagini', 'genesis-theme-cr' ), 'description' => __( 'Di seguito puoi inserire e ordinare le immagini. <strong>DIMENSIONE CONSIGLIATA: 1000x668px.</strong><br /><br />Nota: - È il contenuto testuale sopra all\'immagine che determina l\'altezza dell\'immagine. <br />Non deve essere corto per permettere la corretta sovrapposizione del colore. <br />Mantenere la lunghezza del contenuto e delle immagini più uniformi possibili, <strong>MEGLIO SE UGUALI</strong>.', 'genesis-theme-cr' ), 'options' => array( 'group_title' => __( 'Immagine {#}', 'genesis-theme-cr' ), 'add_button' => __( 'Aggiungi immagine', 'genesis-theme-cr' ), 'remove_button' => __( 'Rimuovi immagine', 'genesis-theme-cr' ), 'sortable' => true, // beta 'closed' => true, // true to have the groups closed by default ), 'data-conditional-id' => PREFIXCMB2 . 'frontpage_image_fonte', 'data-conditional-value' => 'libere', ), ) );

IT WORKS
$cmb_cr_frontpage_image->add_group_field( $cmb_cr_frontpage_image_id, array( 'name' => __( 'Immagine', 'genesis-theme-cr' ), 'desc' => __( '', 'genesis-theme-cr' ), 'id' => PREFIXCMB2 . 'frontpage_image_group_image', 'type' => 'file', 'attributes' => array( 'data-conditional-id' => PREFIXCMB2 . 'frontpage_image_fonte', 'data-conditional-value' => 'libere', ), ) );

I apologize if I have not explained well.
Thanks, Claudio

@K15Lmk98
Copy link
Author

Hello,
I do not know if it's the correct way, but I've solved it with a little bit of personal javascript.

if ( selectedValue == "posts" ) { frontpage_image_group . hide(); } else if (selectedValue == "libere") { frontpage_image_group . show(); } else { // }

Claudio_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant