I'm using an ACF field from the options page to populate a Gravity Forms drop down. The values are pulling from the field but displaying at the top of the form (in preview), not in the drop down. I'm sure this is an issue in how I'm building the form. Thanks for help in advance!
See Screenshot
//gravity forms dynamically populate from ACF
add_filter( 'gform_pre_render_1', 'populate_posts' );
add_filter( 'gform_pre_validation_1', 'populate_posts' );
add_filter( 'gform_pre_submission_filter_1', 'populate_posts' );
add_filter( 'gform_admin_pre_render_1', 'populate_posts' );
function populate_posts( $form ) {
global $choices;
foreach ( $form['fields'] as &$field ) {
if ( $field->type != 'select' || strpos( $field->cssClass, 'populate-posts' ) === false ) {
continue;
}
if( have_rows('core_values', 'option') ):
while( have_rows('core_values', 'option') ): the_row();
$choices[] = array( 'text' => the_sub_field('value_mstr_name'), 'value' => the_sub_field('value_mstr_name') );
endwhile;
// update 'Select a Post' to whatever you'd like the instructive option to be
$field->placeholder = 'Select a Post';
$field->choices = $choices;
endif;
}
return $form;
}