Repeatable group using cmb2_metabox_form saves only the first group
-
If I use a repeatable group on the “options-page” using cmb2_metabox_form, it is able to display/add/remove the groups but on saving it only saves the first group.
I’ve checked the $_POST data in the method cmb2_print_metabox_form in helper-functions.php method and it contains only the first group.
register cmb2 as per the code below
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' ); function yourprefix_register_demo_metabox() { $cmb = new_cmb2_box( array( 'id' => 'images', 'hookup' => false, 'show_on' => array( // These are important, don't remove 'key' => 'options-page', 'value' => array( 'images' ) ), ) ); $group_id = $cmb->add_field( array( // Field Config... ) ); $cmb->add_group_field( $group_id, ....); // Additional fields... }
In a separate page, show the form using
cmb2_metabox_form("images", "images", array( 'cmb_styles' => true ) );
Add more than 1 group and Save
The page is reloaded with only the first group’s values. The others are discarded/not saved.Note: If I use the repeatable group inside a post/page by specifying
object_types=array('post')
it is able to capture all the group data
- The topic ‘Repeatable group using cmb2_metabox_form saves only the first group’ is closed to new replies.