Hi, is there a way to make the repeater field write only?
I’d like the editors to be able to leave notes in a repeater field for each other but I don’t want them to be editable or removeable.
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();
});
});
EDIT: Sorry, wrong post!
That’s the one. Okay, so I assume I’d be replacing:
$(element).find('.acf-input input').attr('readonly', true);
with something like:
$(element).find('div[data-name="FIELD_NAME_HERE"] input').attr('readonly', true);
Correct?
Well that’s better than what I had originally, so thank you. Shame there’s no unique ID field available to repeaters!
The topic ‘Write only repeater field’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.