[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.
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.
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
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.