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

This topic contains 5 replies, has 2 voices, and was last updated by  Anh Tran 2 days, 7 hours 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 5 replies - 1 through 5 (of 5 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.

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

You must be logged in to reply to this topic.