
Hi everyone,
i need to build a form which will be able to fill select box with data from other field and i found this really simple code:
function acf_load_acti_field_choices( $field ) {
// reset choices
$field['choices'] = array();
// if has rows
if( have_rows('activities', 260) ) {
// while has rows
while( have_rows('activities', 260) ) {
// instantiate row
the_row();
// vars
$name = get_sub_field('name');
$name2 = get_sub_field('title_2');
$label = get_sub_field('subtitle');
// append to choices
$field['choices'][ sanitize_title($name.$name2) ] = $name." ".$name2;
}
}
wp_reset_postdata();
// return the field
return $field;
}
add_filter('acf/load_field/name=activities_select', 'acf_load_acti_field_choices');
And everything is fine until I add other filter which try to get data from other field on this same page:
function acf_load_trainer_field_choices( $field ) {
// reset choices
$field['choices'] = [];
if( have_rows('crew', 260) ) {
// while has rows
while( have_rows('crew', 260) ) {
// instantiate row
the_row();
// vars
$name = get_sub_field('name');
// append to choices
$field['choices'][ sanitize_title($name) ] = $name;
}
}
// return the field
return $field;
}
add_filter('acf/load_field/name=trainer_select', 'acf_load_trainer_field_choices');
Then i got 503 error and this cames up in the log file:
Should I execute some extra function before trying get field data ?