I am using a repeater field type of a field.The parent field name is ‘map_details’ and the sub field name is ‘name_of_county’ which is a select dropdown list.
Now I want to display all the values of that select box in the frontend.My code is
$field_key = "field_535befe551ba5"; //field key of parent
$field = get_field_object($field_key);
if( $field )
{
echo '<select name="' . $field['key'] . '">';
foreach( $field['choices'] as $k => $v )
{
echo '<option value="' . $k . '">' . $v . '</option>';
}
echo '</select>';
}
it’s not working as I have given the field key of parent not the sub field which is basically a select box.Also I can’t find the field key for the sub field.
How can I display the sub field dropdown box with values and keys in the frontend.
I recently find the way to output the values/keys in the frontend:
In these cases, I always print_r the parent array (between ‘pre’ tags) in order to understand what’s going on, trust me… it helps.
As in a repeater, the select field (sub_field) is one step deeper in the array, so:
I hope it helps!