cmb2-conditionals icon indicating copy to clipboard operation
cmb2-conditionals copied to clipboard

Does it work with hidden fields?

Open fakeartist opened this issue 8 years ago • 0 comments

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',
            ),
        ));

fakeartist avatar Mar 29 '17 11:03 fakeartist