Support

Account

Home Forums ACF PRO Allow admin to sort a list using Repeater field Reply To: Allow admin to sort a list using Repeater field

  • Hi @cfxd

    Thanks for the question.

    I’m sure this will be possible by hooking into the acf/prepare_field filter and modifying the sub field’s value / disbaled settings.

    Something like this should work:

    
    $GLOBALS['acf_item_count'] = 0;
    
    function acf_prepare_field_item( $field ) {
    	
    	// set disabled
    	$field['disabled'] = 1;
    	
    	
    	// set value
    	if( empty($field['value']) ) {
    		
    		// incease count
    		$GLOBALS['acf_item_count']++;
    		
    		
    		// set value
    		$field['value'] = $GLOBALS['acf_item_count'];
    		
    	}
    	
    	
    	// return
    	return $field;
    	
    }
    
    add_filter('acf/prepare_field/key=field_5600966e8fad1', 'acf_prepare_field_item', 10, 1);
    

    The only issue is that by setting a select field to ‘disabled’, it won’t save it’s value… perhaps instead, you will need to change the $field['class'] to ‘disabled’, and then add some CSS / JS to prevent the select field from being clicked / changed.

    Good luck