-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeatable and sortable group with repeatable fields, issue with group shift #1426
Comments
Can confirm odd behavior but do not have an answer for a solution. |
Instead of copying values I've tried swap group boxes approach and so far it works ok. It requires changed function makeRepeatableSortable from issue #1428 cmb.shiftRows = function( evt ) {
evt.preventDefault();
var $this = $( this );
var moveUp = $this.hasClass( 'move-up' ) ? true : false;
var $from = $this.parents( '.cmb-repeatable-grouping' );
var $goto = moveUp ? $from.prevAll( '.cmb-repeatable-grouping:first' ) : $from.nextAll( '.cmb-repeatable-grouping:first' );
cmb.triggerElement( $this, 'cmb2_shift_rows_enter', $this, $from, $goto );
if ( ! $goto.length ) {
return;
}
cmb.triggerElement( $this, 'cmb2_shift_rows_start', $this, $from, $goto );
var fromIterator = $from.attr('data-iterator');
var gotoIterator = $goto.attr('data-iterator');
$from.attr( 'data-iterator', gotoIterator ).find( cmb.repeatEls ).each( function () {
var $this = $( this );
var name = $this.attr( 'name' );
if ( 'undefined' !== typeof name ) {
var $newName = name.replace( '[' + fromIterator + ']', '[' + gotoIterator + ']' );
$this.attr( 'name', $newName );
}
});
$goto.attr( 'data-iterator', fromIterator ).find( cmb.repeatEls ).each( function () {
var $this = $( this );
var name = $this.attr( 'name' );
if ( 'undefined' !== typeof name ) {
var $newName = name.replace( '[' + gotoIterator + ']', '[' + fromIterator + ']' );
$this.attr( 'name', $newName );
}
});
if( moveUp ){
$goto.before( $from.clone() );
}
else {
$goto.after( $from.clone() );
}
$from.remove();
cmb.makeRepeatableSortable( moveUp ? $goto.prevAll( '.cmb-repeatable-grouping:first' ) : $goto.nextAll( '.cmb-repeatable-grouping:first' ) )
// shift done
cmb.triggerElement( $this, 'cmb2_shift_rows_complete', $this, $from, $goto );
}; |
Your solution is interesting, but it will need to be tested with every field type (which supports being in a repeatable group) to make sure there aren't any regressions. We have to be very careful about backwards compatibility with CMB2, or we could break things for a lot of people. |
I could not agree more, test everything before adding it. Since it works for my application I'm serving modified script via WP hook so I'm good. |
Hi All, I'm also running into this issue. Any updates? Thank you! |
…oups Update shiftRows functionality to be more simple, and fix issues with JS initialization. Fixes #1426
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
The text was updated successfully, but these errors were encountered: