This topic contains 2 replies, has 2 voices, and was last updated by  onpc 9 months, 1 week ago.

  • Creator
    Topic
  • #13230

    onpc
    Participant

    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 ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #13332

    Anh Tran
    Keymaster

    Hi, I’ve tried your code and it seems to be working fine. Here is my video: http://recordit.co/FupVhWSulF. Can you please take a look?

    #13342

    onpc
    Participant

    Hi Anh,

    Thanks for your answer ! Well, I have to go deeper in my code to find what is wrong

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.