Home › Forums › General Issues › Conditional logic across rows in a repeater field
Hello, I would like to know if the conditional logic works across multiple rows in a repeater field.
What I need to achieve: 3 images with layering (top, middle and bottom).
How I was thinking of doing: A repeater field with an image field and 2 checkboxes (Top layer and bottom layer) with conditional logic that hides already selected checkbox.
I would like the specific layer checkbox to be disabled/hidden if that layer has been selected in a previous row.
I have tried but does not seem to work. Any ideas.
No, this cannot be done with ACF, what you are looking for is basically a radio field that works across the rows of a repeater. Something like this would need to
be custom built for your specific repeater and fields.
What version of ACF are you using?
I’m using the last version of ACF 5.4.2.
I’m not sure how to custom build that but I guess I could achieve it via jquery.
Is it something that could be implemented in the future?
Thanks
I have an example of how to do this with a single true/false field here https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/unique-repeater-checkbox.
Thanks for the code.
I tried implementing it but it gives me this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /home/iriscenti2016/public_html/2016/wp-includes/plugin.php on line 524
I think it is the “$this” in the add_action that causes it.
If I remove the array and leave only “unique_repeater_checkbox_enqueue_script” it does not give the error anymore and seems to work.
One last question, what should the “var $list” be if I have 2 fields?
Thanks for your time.
Yep, that was the problem. I’m too used to working with classes I guess. I also copied that portion of code from a custom plugin I did for a client. It was already working so I just modified as needed and didn’t test, seems I missed something.
Thanks for you feedback.
I managed to make it work across two sets of checkboxes within a flexible content repeater field.
Works perfectly.
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!
We’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.