Home › Forums › General Issues › Populate Gravity form fields with ACF subfield values based on dropdown select › Reply To: Populate Gravity form fields with ACF subfield values based on dropdown select
Okay, I think I managed it this way:
add_action( 'gform_pre_submission_1', 'gf_override_field_with_choice_label' );
function gf_override_field_with_choice_label( $form ) {
$post_id = get_query_var('course');
$startdate = rgpost( 'input_38' );
$first_row_value = get_post_meta($post_id, 'course_info_0_startdate', true);
$second_row_value = get_post_meta($post_id, 'course_info_1_startdate', true);
if ($startdate == $first_row_value) {
$_POST['input_40'] = get_post_meta($post_id, 'course_info_0_location', true);
} else if ($startdate == $second_row_value {
$_POST['input_40'] = get_post_meta($post_id, 'course_info_1_location', true);
} else {
$_POST['input_42'] = 'no value';
}
}
Don’t know whether there would be an easier/cleaner way? Or is this the right way?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.