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
- This topic has 6 replies, 2 voices, and was last updated 6 years, 7 months ago by
Lisa Tally.
-
AuthorPosts
-
October 4, 2018 at 12:59 AM #11521
Lisa Tally
ParticipantI 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.
October 4, 2018 at 4:51 PM #11533Anh Tran
KeymasterHi Purdue,
I guess the problem comes from the group settings. Please share the code of the meta box for debugging.
October 4, 2018 at 7:15 PM #11538Lisa Tally
ParticipantI 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; }
October 5, 2018 at 9:29 AM #11546Anh Tran
KeymasterHi 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.
October 5, 2018 at 7:41 PM #11547Lisa Tally
ParticipantGreat. I look forward to the update.
October 6, 2018 at 8:53 AM #11553Anh Tran
KeymasterHi, I've just updated the plugin. Please check it.
Thanks
October 8, 2018 at 8:40 PM #11570Lisa Tally
ParticipantThat 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!
-
AuthorPosts
- You must be logged in to reply to this topic.