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

This topic contains 6 replies, has 2 voices, and was last updated by  Purdue Alumni Association 6 months, 2 weeks ago.

  • Creator
    Topic
  • #11521
    Resolved
    Purdue Alumni Association
    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #11533

    Anh Tran
    Keymaster

    Hi Purdue,

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

    #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;
    }
    #11546

    Anh Tran
    Keymaster

    Hi Purdue,

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

    #11547

    Great. I look forward to the update.

    #11553

    Anh Tran
    Keymaster

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

    Thanks

    #11570

    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 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.