Custom Fields
Re-Envisioned
Support Meta Box Group Group not working properly

This topic contains 5 replies, has 3 voices, and was last updated by  Anh Tran 6 days ago.

  • Creator
    Topic
  • #13137
    Resolved
    Dragan
    Participant

    I created a group using MB Builder and set it to:

    • collapsible true
    • default_state collapsed

    and added some fields with default values and conditional logic.
    NOTE: my fields work perfectly when not in group

    The result is:

    • The group is not collapsed
    • There is no visual indication that there is a group at all
    • The fields are just displayed as if they are not in a group
    • Default values of fields are not set (aka lost)

    Is there a bug or limitations with the group extension?

    the code:

    <?php
    
    add_filter( 'rwmb_meta_boxes', 'mytheme_register_meta_boxes' );
    function mytheme_register_meta_boxes( $meta_boxes ) {
    
        $meta_boxes[] = array (
            'title' => 'Category custom options',
            'id' => 'dmb-cat-single-options',
            'fields' => array(
                array (
                    'id' => 'dmb_cat_group_top_page_content',
                    'type' => 'group',
                    'name' => 'Top page content',
                    'fields' => array(
                        // MAIN MENU
                        array(
                            'type' => 'heading',
                            'name' => 'Main menu',
                        ),
    
                        // [select] Show main menu yes no
                        array (
                            'id' => 'dmb_cat_main_menu_yesno',
                            'name' => 'Show main menu?',
                            'type' => 'select_advanced',
                            'placeholder' => 'Select an Item',
                            'options' => array(
                                'yes' => 'Yes',
                                'no' => 'No',
                            ),
                            'std' => 'yes', 
                        ),
                        // [select] Custom main menu
                        array (
                            'id' => 'dmb_cat_main_menu_custom_yesno',
                            'name' => 'Change default main menu?',
                            'type' => 'select_advanced',
                            'placeholder' => 'Choose',
                            'options' => array(
                                'yes' => 'Yes',
                                'no' => 'No',
                            ),
                            'std' => 'no', 
                            'hidden' => array( 'dmb_cat_main_menu_yesno', '=', 'no' ),
                        ),
                        // [select] Main menu - menu select
                        array (
                            'id' => 'dmb_cat_main_menu_select',
                            'name' => 'Select main menu',
                            'type' => 'select_advanced',
                            'placeholder' => 'Select a menu',
                            'options' => array(
                                'main' => 'Main menu',
                                'footer' => 'Footer menu',
                            ),
                            'visible' => array(
                                array( 'dmb_cat_main_menu_yesno', '=', 'yes' ),
                                array( 'dmb_cat_main_menu_custom_yesno', '=', 'yes' )
                            ),
                        ),
    
                    ),
                    'default_state' => 'collapsed',
                    'collapsible' => true,
                    'group_title' => 'Top page content',
                ),
            ),
            'taxonomies' => array(
                0 => 'category',
            ),
        );
        return $meta_boxes;
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #13159

    Anh Tran
    Keymaster

    Hi Dragan,

    I’ve just checked your code and the functionality works. However, the UI for collapsible group is bad and need to update. Here is my screenshot:

    https://screenshots.firefox.com/CXW5u58MDPx6uxLS/localhost

    I’ll update the group to address this issue.

    Thanks for letting me know.

    #13175

    Ale
    Participant

    I’m having similar issues with std values not being added, I’ve updated today
    Meta Box Group to Version 1.2.18 and Metabox to Version 4.16.1.

    Is there any upcoming update that will fix this?

    #13359

    Anh Tran
    Keymaster

    Hey guys, the appearance and std value bugs are fixed in the latest version. Please update.

    #13362

    Ale
    Participant

    This is great and std is working as expected.

    Not sure if I should open a new topic but now the values from a field inside a group aren’t being copied when a field is in a group. Each clonable group has ‘clone_default’ => true

    #13381

    Anh Tran
    Keymaster

    Hi Ale, did you set clone_default per sub-field?

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

You must be logged in to reply to this topic.