Support

Account

Home Forums General Issues Conditional logic across rows in a repeater field

Solved

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

  • 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.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Conditional logic across rows in a repeater field’ is closed to new replies.