Creating Default Entries within a Repeatable Group
-
Wondering how I would approach creating some default entries within the repeatable group type?
ie. I have a Meta Box “Meta Group” with a repeatable group of a text input & text area, and I would like to be able to have a few defaults populated, with the option to create more.
Here’s my code.
$meta_boxes['meta_group'] = array( 'id' => 'meta_group', 'title' => __( 'Meta Group', 'cmb2' ), 'object_types' => array( 'post', ), 'closed' => true, 'fields' => array( array( 'id' => $prefix . 'meta_group', 'type' => 'group', 'options' => array( 'group_title' => __( 'Meta Group {#}', 'cmb2' ), 'add_button' => __( 'Add Paragraph', 'cmb2' ), 'remove_button' => __( 'Remove Paragraph', 'cmb2' ), 'sortable' => false, // beta ), 'fields' => array( array( 'name' => 'Title', 'default' => 'Title ', 'id' => 'title', 'type' => 'text', ), array( 'name' => 'Description', 'id' => 'description', 'type' => 'textarea', ), ), ), ), );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Creating Default Entries within a Repeatable Group’ is closed to new replies.