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

Does not work on nested items

Open fakeartist opened this issue 9 years ago • 1 comments

Hi! First of all, an excellent addition to cmb2!

I have the following settings:

    $event_metaboxes->add_field(array(
        'id' => $prefix . 'repeatable',
        'name' => 'Repeatable event',
        'type' => 'radio_inline',
        'options' => array(
            'yes' => __('Yes', 'cmb2'),
            'no' => __('No', 'cmb2'),
        ),
        'default' => 'no',
    ));

    $event_metaboxes->add_field(array(
        'id' => $prefix . 'repetition',
        'name' => __('Event repetion', 'cmb2'),
        'type' => 'radio',
        'options' => array(
            'daily' => __('Daily', 'cmb2'),
            'weekly' => __('Weekly', 'cmb2'),
            'monthly' => __('Monthly', 'cmb2'),
            'yearly' => __('Yearly', 'cmb2'),
        ),
        'default' => 'daily',
        'attributes' => array(
            'data-conditional-id' => $prefix . 'repeatable',
            'data-conditional-value' => 'yes',
        ),
    ));
    
    $event_metaboxes->add_field(array(
        'id' => $prefix . 'repetition_daily',
        'name' => __('Event repetion', 'cmb2'),
        'type' => 'radio',
        'options' => array(
            'n' => __('Every N day', 'cmb2'),
            'workday' => __('Every workday', 'cmb2'),
        ),
        'default' => 'n',
        'attributes' => array(
            'data-conditional-id' => $prefix . 'repetition',
            'data-conditional-value' => 'daily',
        ),
    ));

The problem is this: When I click the Yes radio on the first field, the second field opens, but is should also open the 3rd field, but it does not. Any ideas what might be wrong?

fakeartist avatar Nov 18 '16 18:11 fakeartist

Also, as a side notice, when the page opens for the first time, the nested conditional logic works great! The problem is, when you later click weekly and the 'No' radio button of the 1st field, and then again the 'Yes' radio button.

fakeartist avatar Dec 09 '16 16:12 fakeartist