Hi. I have a form with a few dropdowns (dynamically populated, if that matters). When it is submitted, I would like to put the show the user’s selections from these dropdowns in the email Notification they receive but I’ve been unable to determine how to do so.
To be clear, if the selected option is: <option value="12345" >Product Name</option>
I want to display “Product Name” in the Notification.
If the dropdown’s ID is 5, {:5:label} will get the dropdown’s label but I’ve not been able to figure out how to get the selected/submitted option’s label. Help?
Merge tags for choice based fields output the choice text by default. Out of the box the merge tag only outputs the choice value if the value modifier is added to the merge tag (e.g. {:5:value}) or if there is no longer a matching choice found in the fields choices property for the stored value. The latter issue can happen if you are using code to populate the array of choices and that code is only running on form display. There are several filters you need to use to populate the choices for the different contexts the field is used. See the following article:
Ahhh… the choices on the dropdowns are being populated via code. I don’t recall if that is only being done on form display but I would not be surprised if that is the case. I will check that and report back. Thank you for the reply!
Re-implementing our dynamic population of the dropdowns in the manner described in the article linked above both correctly adds the options to the dropdown (mostly, more on this below) and allows the selected option to appear in the Notification correctly (Instead of always showing the value property). Interestingly, just using gform_pre_render isn’t enough. I didn’t figure out which of the other 3 hooks are specifically required (maybe all of them?) because I ran into other issues.
When using gform_pre_render you can only set the text, value, isSelected, and price properties on a choice/option. Unfortunately, we’re using a couple data- properties to store data. We do this because we’ve a couple cases where the selection made in dropdown A determines the data available in dropdown B. Sigh. I see there is a Chained Select Fields add-on but, as luck would have it, my client’s GF sub is expired so I can’t take a look at that.
Anyway, not sure what path we’re going to take just yet but I promised to report results.