Hi everyone !
I have this simple code to fill select box with data pulled from other field
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');
Everything works find until I not try to do this some for other field. After adding other filter on load_field event with code like this:
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');
I got 503 code error and this cames up in the log file:
[Thu Apr 04 12:27:50.853017 2019] [proxy_fcgi:error] [pid 14595:tid 140229314660096] [client XX.XX.XX.XX:58723] AH01067: Failed to read FastCGI header, referer: http://localhost/wp-admin/
[Thu Apr 04 12:27:50.853050 2019] [proxy_fcgi:error] [pid 14595:tid 140229314660096] (104)Connection reset by peer: [client XX.XX.XX.XX:58723] AH01075: Error dispatching request to : , referer: http://localhost/wp-admin/
This behaviour is not related to any specific field. Problem exist only when I try load more than one field in filters. Should I execute some extra function before trying load other field ?