Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Hide/Show fields on select type

This topic contains 7 replies, has 2 voices, and was last updated by  Anh Tran 5 months, 1 week ago.

  • Creator
    Topic
  • #14050

    dave.meta
    Participant

    Hello !

    I need your help because I try to hide and show some fields.
    When I select carousel or gallery, the group ‘modules_slides’ show, but I want for example the field id ‘module_slide_legend’ show only if the ‘module_type’ is ‘carousel’. The condition doesn’t work now, but I think before it worked.

    Can someone help me ?

    Thanks.

    
    array(
           'name'       => 'Slides',
           'id'         => PREFIX . 'module_slides',
           'type'       => 'group',
           'clone'      => true,
           'sort_clone' => true,
           'visible'    => array(
               'when' => array(
                         array(PREFIX . 'module_type', '=', 'carousel'),
                         array(PREFIX . 'module_type', '=', 'gallery'),
                ),
                'relation' => 'or',
            ),
    
    
    array(
                'name'    => 'Légende',
                'id'      => PREFIX . 'module_slide_legend',
                'type'    => 'wysiwyg',
                'options' => array(
                            'media_buttons' => false,
                            'wpautop'       => false,
                            'textarea_rows' => '5',
                 ),
                 // 'visible'    => array(
                 //     'when' => array(
                 //         array(PREFIX . 'module_type', '=', 'carousel'),
                 //     ),
                 //     'relation' => 'or',
                 // ),
    ),
    
Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #14063

    Anh Tran
    Keymaster

    Hi Dave,

    The condition looks simple and should work. Do you put them in different groups?

    #14068

    dave.meta
    Participant

    Hello !

    Thank you for the response. At the bottom you can see how I set the condition, I have a clone group call ‘modules’ and in this group I can choose if I want to have a carousel, a image… and if I choose ‘carousel’ or ‘gallery’, I can set a ‘module_slides’ in where I want the field ‘module_slide_legend’ display only if I choose ‘carousel’, I comment the condition because it doesn’t work and the field were not displayed.

    https://ghostbin.com/paste/7j38q

    Thanks

    #14085

    Anh Tran
    Keymaster

    Hi Dave,

    I see the problem. At the moment, the conditions works only if both fields are in a same group clone. I see the module type is outside of the group where the editor belongs to. So it’s not working.

    #14186

    dave.meta
    Participant

    Hello !

    Thanks for the response.

    And it’s a bug or it’s normal ?

    #14199

    Anh Tran
    Keymaster

    Hi Dave,

    It’s normal. Since when you have multiple clones, it’s impossible to know which clone is affected by the value of the selected field.

    #14945

    dave.meta
    Participant

    Hello !

    Thanks for the response.

    Since the last response, I try a lot of fixes, the first one is I try to downgrade the Metabox Conditionnal Logic from 1.6.5 to 1.5.5, and the fields which has dissapear came back, but the admin page is very very slow..

    Now I use the version 1.6.5 and the WP admin page is faster, but the fields has dissapear again..

    The problem is the condition in a clone of a clone is not reading by the Metabox Conditionnal Logic, so I comment some lines like this in all my clone of a clone.

    I didn’t understand why it works on 1.5.5 and not in 1.6.5 ?

    If you can enlighten me in this bug ?

    Thanks.

            
    array(
           'name'    => 'CTA lien PDF (uniq. pushs avec lien)',
           'id'      => PREFIX . 'module_push_link_pdf',
                        'type'    => 'file_advanced',
                        'class'   => 'warning-red',
                         // 'visible' => array(
                         //     'when' => array(
                         //         array(PREFIX . 'module_type', '=', 'pushs-link'),
                         //     ),
                         //     'relation' => 'or',
                         // ),
    ),
    #14955

    Anh Tran
    Keymaster

    Hi Dave,

    I’ve just push a fix for Meta Box Conditional Logic extension. Now that works for elements outside cloneable groups.

    The update for Meta Box AIO will come later.

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

You must be logged in to reply to this topic.