Adding a Group causes an warning: Argument #2 should be an array

Support MB Builder Adding a Group causes an warning: Argument #2 should be an arrayResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11521
    Lisa TallyLisa Tally
    Participant

    I am using the builder to create a custom meta box with a group. I get the following error when trying to save:

    Warning: array_map(): Argument #2 should be an array in [my-site-info]/wp-includes/post.php on line 2072
    
    Warning: Cannot modify header information - headers already sent by (output started at [my-site-info]/wp-includes/post.php:2072) in [my-site-info]/wp-includes/pluggable.php on line 1219

    If I remove the group the data saves successfully.

    Please help.

    #11533
    Anh TranAnh Tran
    Keymaster

    Hi Purdue,

    I guess the problem comes from the group settings. Please share the code of the meta box for debugging.

    #11538
    Lisa TallyLisa Tally
    Participant

    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;
    }
    #11546
    Anh TranAnh Tran
    Keymaster

    Hi Purdue,

    Thanks a lot for bug reporting. I can replicate the bug in the MB Builder (it's a bug in the Builder, not in the Group extension). I'll fix and release a new version soon.

    #11547
    Lisa TallyLisa Tally
    Participant

    Great. I look forward to the update.

    #11553
    Anh TranAnh Tran
    Keymaster

    Hi, I've just updated the plugin. Please check it.

    Thanks

    #11570
    Lisa TallyLisa Tally
    Participant

    That seems to have worked. I will let you know if I experience any issues using it in production, but thank you for your quick reply and fix!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.