jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does it work with hidden fields?

fakeartist opened this issue · 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',
            ),
        ));