repeatable field in field group not working properly after deleting a group
-
Hey!
I made a video to explain the problem: https://www.youtube.com/watch?v=6SDiE5b_EjU&feature=youtu.be
I’m using cmb2 Version 2.2.2.1 with WordPress 4.5.3
This is my metabox code:
$prefix = 'lg_'; /** * Sample metabox to demonstrate each field type included */ $cmb_demo = new_cmb2_box( array( 'id' => 'lg_metabox', 'title' => 'Test Element', 'object_types' => array( 'page', ), // Post type ) ); $cmb_demo->add_field( array( 'name' => 'Test Text', // 'desc' => 'field descr', 'id' => 'lg_text', 'type' => 'text', 'default' => 'John', // 'sanitization_cb' => 'my_custom_sanitization', // custom sanitization callback parameter // 'escape_cb' => 'my_custom_escaping', // custom escaping callback parameter // 'on_front' => false, // Optionally designate a field to wp-admin only 'repeatable' => true, // 'column' => true, // Display field value in the admin post-listing columns ) ); $cmb_demo->add_field( array( 'name' => __( 'Test Color Picker', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => 'lg_colorpicker', 'type' => 'colorpicker', 'default' => '#00ffff', 'attributes' => array( 'data-colorpicker' => json_encode( array( 'palettes' => array( '#3dd0cc', '#ff834c', '#4fa2c0', '#0bc991', ), ) ), ), ) ); $group_field_id = $cmb_demo->add_field( array( 'id' => 'lg_test_repeat_group', 'type' => 'group', 'description' => __( 'Generates reusable form entries', 'cmb2' ), // 'repeatable' => false, // use false if you want non-repeatable group 'options' => array( 'group_title' => __( 'Entry {#}', 'cmb2' ), // since version 1.1.4, {#} gets replaced by row number 'add_button' => __( 'Add Another Entry', 'cmb2' ), 'remove_button' => __( 'Remove Entry', 'cmb2' ), 'sortable' => true, // beta // 'closed' => true, // true to have the groups closed by default ), ) ); // Id's for group's fields only need to be unique for the group. Prefix is not needed. $cmb_demo->add_group_field( $group_field_id, array( 'name' => 'Entry Title', 'id' => 'title', 'type' => 'text', 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) ) ); $cmb_demo->add_group_field( $group_field_id, array( 'name' => 'Description', 'description' => 'Write a short description for this entry', 'id' => 'description', 'type' => 'textarea_small', ) ); $cmb_demo->add_group_field( $group_field_id, array( 'name' => 'Entry Image', 'id' => 'image', 'type' => 'file', ) ); $cmb_demo->add_group_field( $group_field_id, array( 'name' => 'Image Caption', 'id' => 'image_caption', 'type' => 'text', ) ); $cmb_demo->add_group_field( $group_field_id, array( 'name' => __( 'Test Taxonomy Radio', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => $prefix . 'text_taxonomy_radio', 'type' => 'taxonomy_radio', 'taxonomy' => 'category', // Taxonomy Slug 'default' => 'dogs' // 'inline' => true, // Toggles display to inline ) ); $cmb_demo->add_field( array( 'name' => __( 'Test Taxonomy Radio', 'cmb2' ), 'desc' => __( 'field description (optional)', 'cmb2' ), 'id' => $prefix . 'text_taxonomy_radio_single', 'type' => 'taxonomy_radio', 'taxonomy' => 'category', // Taxonomy Slug 'default' => 'dogs' // 'inline' => true, // Toggles display to inline ) );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘repeatable field in field group not working properly after deleting a group’ is closed to new replies.