Hi I work with clients that use the GF plugin (and have registered keys) and while doing some custom implementation I ran into what seems like a bug with the gform_field_map_choices
filter.
The field used to target one individual choice at a time in a loop but now it targets all of them.
I believe the filter used to be inside the loop while checking and adding each choice inside the method Generic_Map::get_value_choices()
in the file ./includes/settings/fields/class-generic-map.php
and the $input_type
could be checked property.
But now the $input_value
parameter is the value of the last looped field but for ALL calls of the filter.
The Doc block for the filter is also inconsistent with the actual parameters passed to the filter.
Again, not sure if this is a bug or maybe an extra filter for singular gform_field_map_choice
needs to be added?
The below check for $input_type
is always be the type of the last field in the form.
<?php
add_filter( 'gform_field_map_choices', function( $choices, $form_id, $input_type ) {
if ( $input_type === 'field_type_to_check' ) {
// cannot do things correctly since the $input_value is always the same, always the type of the last field in the form.
}
return $choices;
}, 10, 3 );