Support

Account

Home Forums Add-ons Options Page Select specific row from repeater

Helping

Select specific row from repeater

  • I have multiple rows setup within a repeater in my options area. Each row consists of a few sub fields.

    What I am trying to achieve is to be able to select a specific row using a select field on a page template.

    Now I’ve read this (http://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/) which helps slightly but still can’t work out how to display all the sub fields from a selected repeater row.

    The link above only shows how to pull the sub field’s data into the select field, not actually select a row from the repeater so I can use all the sub field data from that row within my template.

    Any help with this would be great.

    Many thanks

    Duncan

  • Hi @skweeze

    Thanks for the post.

    You need to note that the select field expects some choices with a value and label and your sub fields should match this criteria. If you have more than two sub fields, you will need to add some logic to extract the values from the repeater array within your foreach loop and append the variables to the select field choices through:

    // append to choices
     $field['choices'][ $value ] = $label;

    I hope this helps.

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

The topic ‘Select specific row from repeater’ is closed to new replies.