Skip Navigation

[Resuelto] Drag and drop reordering of repeating image field not being saved

This support ticket is created hace 1 año, 1 mes. There's a good chance that you are reading advice that it now obsolete.

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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Minesh hace 1 año, 1 mes.

Asistido por: Minesh.

Autor
Mensajes
#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

Idiomas: Inglés (English )

Zona horaria: 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?