Passing value instead of text in URL parameter on form submission [RESOLVED]

I’m populating a select field called ‘effectivedate’ dynamically with dates, where the text format is formatted as ‘March 1, 2021’, and the value formatting is ‘03/01/2021’. This is working fine. :slight_smile: Here’s the snippet of my code:

    foreach ($form['fields'] as &$field) {
		if ($field->inputName == 'effectivedate') {
			$choices = [];
			foreach ( $dates as $k => $date ) {
	            $choices[] = array( 'text' => $date, 'value' => $k );
	        } 
			$field->choices = $choices;
		}
	}

When I pass this data to the next page via URL parameter. I have it set up on the confirmation page as &effectivedate={When do you want your benefits to begin?:15}, and when it adds the parameter to the URL, it shows up as: &effectivedate=March+1st%2C+2021. Is there a way to indicate that I want to pass the parameter with the value (03/01/2021) and not the text, or do I need to get the parameter and reformat it?

PS, I also have radio buttons that are passing the text of the selected radio button instead of the value: &gender={Gender:5} returns &gender=Female instead of ‘F’ (which is the value set for this radio button). I’d prefer to not have to go through and reformat all parameters that do this, if possible.

Thanks! :slight_smile:

You can use the merge tag modifier :value. For example, {:15:value} or {Gender:5:value}

2 Likes

In all my years of using Gravity Forms, I had no clue that was a thing. Awesome, and thank you!!

2 Likes
© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.