Skip to content

Repeatable and sortable group with repeatable fields, issue with group shift #1426

Description

@milutinjaric
add_action( 'cmb2_admin_init', function(){
	
	$cmb = new_cmb2_box([
		'id'            => 'metabox_attachment',
		'title'         => 'TEst',
		'object_types'  => [ 'page' ], // Post type
		'priority'      => 'high',
		'show_names'    => true
	] );

	$group_field_id = $cmb->add_field( array(
		'id'          => 'wiki_test_repeat_group',
		'type'        => 'group',
		'description' => __( 'Generates reusable form entries', 'cmb2' ),
		'repeatable'  => true,
		'options'     => array(
			'group_title'       => __( 'Entry {#}', 'cmb2' ), 
			'add_button'        => __( 'Add Another Entry', 'cmb2' ),
			'remove_button'     => __( 'Remove Entry', 'cmb2' ),
			'sortable'          => true,
		),
	) );

	$cmb->add_group_field( $group_field_id, array(
		'name' => 'Entry Title 2',
		'id'   => 'subtitle',
		'type' => 'text',
		 'repeatable' => true,
		 'sortable' => true
	) );

});

Step 1.
In first group click to repeat field and populate both https://prnt.sc/13o8bn2

Step 2.
Add another group ( Add another Entry )

Step 3.
Click move down on first group.

Result:
Only first field from group 1 is transferred to group 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions