Custom Fields
Re-Envisioned
Support Meta Box Builder Adding a Group causes an warning: Argument #2 should be an array Reply To: Adding a Group causes an warning: Argument #2 should be an array

#11538

I am using all the default settings. By simply placing an empty group in the Fields area I get the error.

add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array (
        'title' => 'Test Box',
        'id' => 'test-box',
        'post_types' => array(
            'page',
        ),
        'context' => 'normal',
        'priority' => 'high',
        'fields' => array(
        ),
    );
    return $meta_boxes;
}

(Looking closer at the code above I see that an empty group is not even output into the Code tab.)

Even with a more realistic example (a group with a field inside it), I still get the error.

add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array (
        'title' => 'Test Box',
        'id' => 'test-box',
        'post_types' => array(
            'page',
        ),
        'context' => 'normal',
        'priority' => 'high',
        'fields' => array(
            
            array (
                'id' => 'group_2',
                'type' => 'group',
                'name' => 'Group',
                'fields' => 
                array (
                    0 => 
                    array (
                        'id' => 'text_2',
                        'type' => 'text',
                        'name' => 'Text Field',
                    ),
                ),
                'default_state' => 'expanded',
            ),
        ),
    );
    return $meta_boxes;
}