I am struggling a bit with this and could use some help. I have an ACF repeater called "gas_grades" and within that repeater I have two fields:
First filed is "grade" and is a text field. Second field is "size" and is a repeater field with a text field.
So, on an individual post I can add the gas grades, and the sizes. 5.5, 6, 6.5, 7, etc.
What I'm attempting to accomplish here is to loop through the grades in a form select field and based on the grade selected in the dropdown will display the sizes for that specific grade in a second dropdown.
The image below demonstrates the current layout of my field group.
Repeater (Gas Grades) Text Field (Grade) Repeater (Size) Text Field (Size) End Repeater (Grade) End Repeater (Gas Grades)
This is the basic repeater loop used to display the data:
@if( have_rows('gas_grades') )
@while( have_rows('gas_grades') )
<?php
the_row();
$grade = get_sub_field('grade');
?>
<option value="">{{ $grade }}</option>
@if( have_rows('size') )
@while( have_rows('size') )
<?php
the_row();
$size = get_sub_field('size');
?>
<option value="">{{ $size }}</option>
@endwhile
@endif
@endwhile
@endif
And then of course, this is the current output:
So, 5.5, 6, and 6.5 would be listed in the first select dropdown, then their sub-repeater fields would be listed in the 2nd dropdown.