I want to populate a text field (id=2) based on whether the user selects the first choice, second choice, third choice or fourth choice (and so on) from a dropdown field (id=1), not depending on the label/value of the selected choice.
Can someone help me what the if statement conditions should look like? Or should I use a switch statement?
If (/* first choice selected in dropdown field with id=1 */) {
add_action( 'gform_pre_submission_1', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
$_POST['input_2'] = 'text-field value A';
} } Else if (/* second choice selected in dropdown field with id=1 */) {
add_action( 'gform_pre_submission_1', 'pre_submission_handler_2' );
function pre_submission_handler_2( $form ) {
$_POST['input_2'] = 'text-field value B';
} }