Home Forums ACF PRO Update Repeater SELECT field


Update Repeater SELECT field

  • Hey guys,

    I am trying to update a select field in a repeater, based on another ACF field.

    I have the following so far, which works, but I need to check if the value exists already to avoid duplicates. Can anyone point out how to correct my code?

    $update_me = get_field('website');
    $field_key = "field_55f2e2b76d08e";
              $value = get_field($field_key);
              $value[] = array("field_55f2e2dc6d08f" => "website", "field_55f2e3256d090" => $update_me);
                if($value != 'website') {
                  update_field( $field_key, $value);

    Thanks so much!

  • I’m not sure I understand what you mean by but I need to check if the value exists already to avoid duplicates Do you mean that you want to see if someone has selected the value already for another post?

  • Hey there John,

    Let me try explain a bit better:

    I have the following field:


    and the following two SELECT fields in a repeater:

    TYPE: (phone, email, website etc)

    When I open the page, I need to check whether the choice “TYPE: Website” exists and has a VALUE. if it does, do nothing. If it doesn’t, update it using the Website field. Otherwise the repeater SELECT field ends up with duplicate website values.

    Hope that makes more sense?

  • Also, is it possible to delete a choice if it is empty? ie, if a repeater has:

    Phone: XXX XXX XXXX
    Cellphone: XXX XXX XXXX
    Email: [email protected]

    Delete the second cellphone choice when opening the page?

  • If it’s all part of the same repeater, maybe.

    you can create an acf/load_value filter on the repeater field

    In this filter you it would be possible to remove duplicate values. The value for the repeater will be a multidimensional array that looks something like this:

    $value = array(
      // there will be a nested array for each row  
        // each field in the row will have a value
        'type' => 'website',
        'value' => ''

    You could loop through the array, record what’s in each row and delete the duplicates, you could also get the value of another field to check to see it that is duplicated as well. At least in theory this might do what you need.

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

The topic ‘Update Repeater SELECT field’ is closed to new replies.