Skip Navigation

[Resolved] Drag and drop reordering of repeating image field not being 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 1 reply, has 2 voices.

Last updated by Minesh 6 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2653099

We are using Toolset Forms for the purposes of front end creation and editing of posts. One of these fields is an Image field which is set to "Allow multiple instances of this field", ie be a repeating field.

Up until sometime earlier this year drop and drop reordering of images was working fine. Now, after software updates, the new order of images does not save when post is saved using the front end form. However, the images can be reordered successfully via the back end.

I checked this on an older development version of the same site (aos.liquidedge.co.nz) where software hadn't been updated. It was running Toolset Forms version 2.6.13 and the drag and drop reordering was working fine. When I updated WordPress from 6.0.6 to 6.3.2 and updated Toolset plugins to latest versions (Forms to 2.6.17) the drag and drop reordering stopped being saved on the dev site too.

I've deactivated all other plugins apart from the four Toolset plugins we are using (Access, Forms, Maps, Types, Views) and this has not solved the problem on the dev site. (I have not attempted this on the live site.)

I have switched on debugging and no errors are being recorded.

I have checked a completely different site that also happens to have a repeating image field on a front end form and the problem is happening there too.

#2653183

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 fortunately I've workaround to share with you.

To save the repeating field (multiple instance filed) order you should add the following code to "Custom Code" section offered by Toolset or to your current theme's functions.php file:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

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 custom image field slug.

#2653511

Excellent, thanks Minesh, that's worked nicely.

Given this is a known issue, I'm surprised my Google and forum searches didn't find the answer earlier. Please advise where this patch was published in your documentation etc?

davidS-53 confirmed that the issue was resolved on 2023-10-17 02:39:29.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.