Hi,
I am trying to populate a select field with a text field from a repeater but it is giving me a 500 error that is difficult to debug.
The repeater is part of the same custom post. Not too much documentation on how to go about this.
thanks,
Paul
add_filter('acf/load_field/name=no_complete_target', 'acf_load_complete_field_choices');
function acf_load_complete_field_choices($field){
$post_id = get_the_ID();
if ( have_rows( 'group', $post_id ) ):
while ( have_rows( 'group', $post_id ) ) : the_row();
if ( have_rows( 'result', $post_id ) ):
while ( have_rows( 'result', $post_id ) ) : the_row();
$title = get_sub_field( 'result_title', $post_id );
// once this works this will be
// $field['choices'] = $title;
echo $title . '';
endwhile;
endif;
endwhile;
endif;
return $field;
}
Hi,
I figured out that this is not possible.
Repeater
– Repeater
-Text Field
– Repeater
Hi,
I figured out that this is not possible.
Repeater
– Repeater
– – Text Field
– Repeater
– – Select Field Loaded from Text Field Above
The error was Trying to get property of non-object
So I rethought the data and realized I dould get rid of one of the parent repeater went with this
– Repeater
– – Text Field (result_title)
– Repeater
– – Select Field Loaded from Text Field Above (yes_complete_target)
The code then is
add_filter('acf/load_field/name=yes_complete_target', 'acf_load_complete_field_choices');
function acf_load_complete_field_choices($field){
global $post;
$post_id = $post->ID;
$field['choices'] = array();
//Get the repeater field values
$choices = get_field( 'dt_result', $post_id );
$keys = array_keys($choices);
for($i = 0; $i < count($choices); $i++) {
foreach($choices[$keys[$i]] as $key => $value) {
if($key == 'result_title'){
$title = $value;
//echo $value . "<br>";
$field['choices'][$title] = $title;
}
}
}
return $field;
}