Support

Account

Home Forums ACF PRO Write only repeater field Reply To: Write only repeater field

  • This is something that I did recently. The client has a repeater that they can add to, but they cannot remove entries or edit existing one. I did this by adding custom JS https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/ and my JS is below. Unfortunately it will not prevent them from dragging and dropping rows to change the order, I’m don’t know how to do that. There seems to be a solution to that here https://support.advancedcustomfields.com/forums/topic/how-to-disable-dragdrop-ordering-function-on-a-specific-repeaters-field/

    
    jQuery(document).ready(function($) {
    	if (typeof(acf) == 'undefined') {
    		return;
    	}
    	
    	var repeaters = [
    		'field_59dd19d721413',
    		'field_59de2a200f0a3',
    		'field_59de3024dff85',
    		'field_59de3fc95cf01',
    		'field_59de4773cb4ee',
    		'field_59de4e4784bac',
    		'field_59e0dec7330d9',
    		'field_59e0d5657109a',
    		'field_59e0e934032c3',
    		'field_59e4d54db8896',
    		'field_59e4d7f348352',
    		'field_59e4ea9adfa00',
    		'field_59e60f342dae3',
    		'field_59e61cce68a09'
    	];
    	var selectors = [];
    	for (i=0; i<repeaters.length; i++) {
    		selectors[selectors.length] = '[data-key="'+repeaters[i]+'"] .acf-row';
    	}
    	var selector = selectors.join(', ');
    	//console.log(selector);
    	$(selector).each(function(index, element) {
    		if ($(element).hasClass('acf-clone')) {
    			return;
    		}
    		$(element).find('.acf-input input').attr('readonly', true);
    		$(element).find('a[data-event="remove-row"]').remove();
    	});
    	
    });