Hey ACF Team,
Had another idea this morning. Sometimes I use the repeater field for rows of content (like rows of 3 image blocks or something, let’s just say)… it would be cool to have a “step size” (for lack of better term)… where you can specify if they want to add more, how many more it HAS to add.
So, for instance, if you set it to 3, everytime they clicked “Add Row” it added 3 at a time (if that’s what you were going for).
Does that make sense?
Of course, you can fake this by just having three required fields INSIDE the repeater field, so when you click add Row it adds all three… so maybe I haven’t thought this all the way through, what do you think?
I don’t think this is something that I’d use. I don’t generally subscribe to creating absolute limits and go by this rule https://en.wikipedia.org/wiki/Zero_one_infinity_rule. For example, what if on a medium size device you want to have rows of 2 instead of 3, before stacking them all on really small devices. I think that the developer would consider something like this an “edge case”.
You could detect when a row is appended, count the current rows and then add enough to make it a number that is a multiple of the number you want. You could also probably detect when one is deleted, add a confirmation and then remove that number of rows. The problem here would be, which of the others to you delete. Your client might be pissed if you arbitrarily delete the ones they want to keep.
A better (and probably simpler) solution might be to create an acf/validate_value filter https://www.advancedcustomfields.com/resources/acf-validate_value/ for the repeater field and count the number of rows submitted and return an error if it does not match what is needed.
You must be logged in to reply to this topic.
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!
© 2023 Advanced Custom Fields.