Hello 🙂
I think there is an issue while using Meta Box Conditional Logic and checkboxes.
Here's my code :
$meta_boxes[] = array(
'title' => 'Popin',
'post_types' => array('page'),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'id' => 'hp-popin',
'type' => 'checkbox',
'name' => 'Afficher une popin ?',
),
array(
'id' => 'hp-popin-title',
'type' => 'text',
'name' => 'Titre ?',
'visible' => array( 'hp-popin', '=', true )
),
array(
'id' => 'hp-popin-title-color',
'type' => 'color',
'name' => 'Couleur du titre ?',
'visible' => array( 'hp-popin', '=', true )
),
array(
'id' => 'hp-popin-text',
'type' => 'textarea',
'name' => 'Texte ?',
'visible' => array( 'hp-popin', '=', true )
),
array(
'id' => 'hp-popin-image',
'type' => 'file_advanced',
'max_file_uploads' => 1,
'name' => 'Image ?',
'visible' => array( 'hp-popin', '=', true )
),
array(
'id' => 'autosize-hp-popin',
'type' => 'checkbox',
'name' => 'Adapter la taille de la popin par rapport à son contenu ?',
'style' => 'rounded',
'on_label' => '<i class="dashicons dashicons-yes"></i> Oui',
'off_label' => '<i class="dashicons dashicons-no"></i> Non',
'visible' => array( 'hp-popin', '=', true )
)
)
);
So, if the checkbox id hp-popin is checked, the others elements are shown. But, if the checkbox id autosize-hp-popin is checked, when publishing the post, the first one is still checked but the others elements are hidden... So, we have to uncheck the first one to display the others elements...
I tried by using the switch element and it is the same behaviour.
Did I make a mistake or is it really a bug ?