Home Forums Add-ons Repeater Field Updating Repeater Sub Field Value based on spécific field value


Updating Repeater Sub Field Value based on spécific field value

    • willio

    • June 19, 2020 at 9:37 am

    Hello I want to modify a value of a repeating field according to a specific value.
    I don’t know whether to use the update_sub_fields function; the problem with this function is that instead of modifying a value according to the line number I want to modify according to a specific value in my table

    Thanks for your help

  • The only way that you can do this would be to loop over the repeater to find the one you’re looking for. Something like this:

    if (have_rows('repeater')) {
      while (have_rows('repeater')) {
        if (get_sub_field('sub_field') == 'something') {
          update_sub_field('sub_field', 'new_value');
    • willio

    • July 1, 2020 at 4:08 am

    Thank you for your answer that solves part of my problem.
    However I have unique values in my acf_form () form with and I want to have a field which allows to insert a unique value and modify a field of the row

        if (have_rows('rsvp')) {
            while (have_rows('rsvp')) {
                if (get_sub_field('unique_id') == '5efb792f219a9') {
                    update_sub_field('confirmation', 'accept');
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

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.