jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox
GNU General Public License v2.0
86 stars 61 forks source link

Does it work with hidden fields? #41

Open fakeartist opened 7 years ago

fakeartist commented 7 years ago

Hi. I have a hidden input and another field. I want, depending of the hidden input's value, to show or hide the other field. I try to do it by using the code below, but it doesn't work. The other field is always hidden. Any ideas why?

$metaboxes->add_field(array(
            'id' => 'hidden_field',
            'type' => 'hidden',
            'default' => '0',
        ));
$metaboxes->add_field(array(
            'name' => 'Hide me',
            'id' => 'conditional_field',
            'type' => 'text',
            'attributes' => array(
                'data-conditional-id' => 'hidden_field',
                'data-conditional-value' => '0',
            ),
        ));