Support

Account

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?