Support

Account

Home Forums Add-ons Repeater Field Dynamic select data in repeater's field

Solved

Dynamic select data in repeater's field

  • I have a repeater field that has 2 select sub-fields and I want to dynamically populate both. The second sub-field choices change depending on what is selected in first sub-field – second select choices could be different for each row.

    So far I got dynamic values initialized for both selects, passed localization data used to change second select via JS.

    When I save post, values are saved correctly but the select fields all reset to initial choices.

    Before save:
    Row1: A – 1, (2), 3
    Row2: A – 1, 2, (3)
    Row3: B – a, b, (c)

    After save:
    Row1: A – 1, (2), 3
    Row2: A – 1, 2, (3)
    Row3: A – (1), 2, 3

    By now I presume you just can’t modify data of fields in individual rows, but please tell me I missed something 🙂

  • https://www.advancedcustomfields.com/resources/acf-prepare_field/

    You might be able to prevent prevent ACF from resetting the values by using an acf prepare field filter. I think this is called for each value. You can get the current value and make sure that it is available as a choice and this should (I think) prevent the value being reset.

  • Thank you so very much! That one indeed fires for every single repeater field. I got the value from first select field, based on that fetched my options and filled them as choices in the second select field 😀

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

The topic ‘Dynamic select data in repeater's field’ is closed to new replies.