Support

Account

Home Forums Add-ons Repeater Field Get fields from a specific repeater, within a nested repeater section

Helping

Get fields from a specific repeater, within a nested repeater section

  • Hello

    What would be the best way to get the fields/data within a nested repeater?

    For example, I have a repeater field, with nested repeaters. I’d like to collect the data from the repeater with the field name “program_id” set to “10”. Alternatively, is it possible to get the fields/data from the repeater using the ID’s / order number within the repeater. So I’d get the fields from the repeater section of a specific order number.

    Looping through every repeater value until I reach the one (example 10) I need should be possible but hoping there is a more simple way?

    Screenshot: https://i.gyazo.com/5a5d2da3c0dcc5c98dbbc70fb9adca9f.png

  • You can get the entire repeater, including nested repeaters

    
    get_field('repeater_name');
    

    or you can get an entire nested repeater

    
    get_sub_field('nested_repeater_name');
    

    this will return the entire contents of the repeater as an array and then you can jump back and forth in the array as you need to.

    But finding a specific value in the repeater will require looping through the array or nested array to find the row you’re looking for in any case.

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

The topic ‘Get fields from a specific repeater, within a nested repeater section’ is closed to new replies.