Home Forums Add-ons Repeater Field Populate select field with values from repeater field Reply To: Populate select field with values from repeater field

  • Hi Elliot!

    If I var_dump($field['name']); it just spits out the field name from when I set up the field string 'elevation' (length=9). Not sure if I did something wrong.

    From the field itself the elevation field ID value is acf-field-field_51e5de8ec13b9_0_field_51e5e09bc13bb_0_field_51eeec9096476 and the adjacent Home selector field ID is acf-field-field_51e5de8ec13b9_0_field_51e5e09bc13bb_0_field_51ef0daeb0698 – Not sure if those help.

    On a side note, before I posted here, I tried messing with some custom fields. I ended up creating a new field just for my elevations, and selecting the post type when I set up the field.

    I started with the post_object field and modified it a little to closer fit my needs. The largest major modification was how the field choices were loaded. Using the conventions already built into the field class I was able to load the elevations grouped by their parent Home.

    Here is that code:

    $elevations = get_field('elevations_repeater', $p->ID);
    if ($elevations) {
    	foreach ($elevations as $el) {
    		$elName = $el['elevation_name'];
    		$field['choices'][ $title ][ $elName ] =  $elName;

    Then all I had to do was change how the value was saved to the database as just the elevation name, so for the time being I have a workaround, but ultimately I’d prefer the functionality I am talking about.