Skip Navigation

[Closed] Repeating Fields Drag & Drop “Sort Order” Not Saved

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 9 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2680687

I am trying to:
Use front end forms to edit a post. The post type uses repeating fields. When I drag & drop the fields to arrange sort order, the changes are not saved (DOES NOT WORK).

When I use the back end WP admin editor to perform the same steps (i.e. drag & drop the fields to arrange sort order), the changes are saved (WORKS).

Link to a page where the issue can be seen:
hidden link
This is the front end form used to manage user profiles.

The Post Field Group is here:
hidden link

The Post Form is here:
hidden link

The Content Template is here:
hidden link

Please be sure to redact those URLs for public display.

Thank you

#2680729

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

This is a known issue to us and the workaround to save the sort order for the repeating field is to use "cred_save_data" form's hook:

You can add the following code to "Custom Code" section offered by Toolset and add a new code snippet (do not forget to activate the code snippet) and add the following code to it:

add_action('cred_save_data', 'ts_save_the_rf_sort_order_manually',10,2);
function ts_save_the_rf_sort_order_manually($post_id, $form_data) {
    // if a specific form
    if ($form_data['id']==99999) {
    		
      	$field_slug = 'media-gallery';

    	$field_content = $_POST['wpcf-'.$field_slug];
      		
      		$sort_order = array();
      	    
      		delete_post_meta($post_id,'wpcf-'.$field_slug);
      
      		foreach($field_content as $k=>$v):
      			$sort_order[] = add_post_meta($post_id,'wpcf-'.$field_slug,$v);
    		endforeach;
   
      		update_post_meta($post_id,'_wpcf-'.$field_slug.'-sort-order', $sort_order);
      
    }
}

Where:
- Replace 99999 with your original form ID
- Replace "media-gallery" with your original field slug

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#benefits-of-adding-custom-code-using-toolset
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#2681460

Hi Minesh,
Thanks for the code snippet. I followed your instructions and applied the code. Unfortunately, the front-end drag & drop sort is still not working.

If you like, I can provide the code snippet and settings I am using or you can log in to see for yourself. Additionally, is it possible to modify the code so that the $field_slug is a an array since more than one field requires drag & drop sort.

Thanks

#2681761

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

That is really strange.

Can you please share problem URL where can I see the issue and in what sort order you want to display what field?

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Repeating Fields Drag & Drop “Sort Order” Not Saved’ is closed to new replies.