Custom Fields
Re-Envisioned
Support Meta Box Group 'default_state' => 'collapsed', not collapsing group on load

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 1 year ago.

  • Creator
    Topic
  • #9969
    Resolved
    makeagency
    Participant

    The group remains open after initial page load.

    I have the follwing metabox extensions installed:

    MB Admin Columns
    MB Revision
    MB Term Meta
    Meta Box Group
    Meta Box Conditional Logic
    Meta Box Include Exclude
    Meta Box Show Hide (Javascript)
    Meta Box Updater

    $meta_boxes[] = array(
        'id'         => 'C_hotel_previews', 
        'title'      => '<img src="'.get_template_directory_uri().'/assets/metabox/img/cpt-hotel-preview.png">',
        'post_types' => array( 'hotels' ),
        'autosave'   => false,
        'context'    => 'normal',
        'priority'   => 'high',
        'fields'     => array(
            array(
                'name' => 'Hotel Previews',
                'type' => "heading",
                'desc' => 'Add an area and include it\'s corresponding images with descriptions.',
            ),
            // GROUP
            array(
                'id'     => 'hotel_area_group',
                'type'   => 'group',
                'clone'  => true,
                'sort_clone' => true,
                'collapsible' => true,
                'default_state' => 'collapsed',
                'group_title' => array( 'field' => "{$prefix}area_title" ),
                'add_button' => '+ Area',
                'fields' => array(
                    // TEXT
                    array(
                        'name' => 'Area Title',
                        'id' => "{$prefix}area_title",
                        'type' => 'text',
                        'label_description' => 'Rooms, Swimming Pool, Restaurant, etc...',
                    ),
                    // GROUP
                    array(
                        'id'     => 'slide_group',
                        'type'   => 'group',
                        'clone'  => true,
                        'sort_clone' => true,
                        'collapsible' => true,
                        'default_state' => 'collapsed',
                        'save_state'  => true,
                        'group_title' => 'Slide {#}',
                        'add_button' => '+ Slide',
                        'fields' => array(
                            // IMAGE
                            array(
                                'name'             => 'Image',
                                'id'               => "{$prefix}slide_group_image",
                                'type'             => 'image_advanced',
                                'force_delete'     => false,
                                'max_file_uploads' => 1,
                                'max_status'       => true,
                            ),
                            // WYSIWYG/RICH TEXT EDITOR
                            array(
                                'name' => 'Description',
                                'id'   => "{$prefix}slide_group_wysiwyg",
                                'type' => 'wysiwyg',
                                'raw'  => false,
                                'options' => array(
                                    'textarea_rows' => 3,
                                    'teeny'         => true,
                                    'media_buttons' => false,
                                ),
                            ),
                        ),
                    ), // end Group
                ),
            ), // end Group 
        ),
     );
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #10059

    Anh Tran
    Keymaster

    Hello, I’ve just tried your code and it works. Did you see any error in the console?

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.