August 31, 2022: Added
gwlfac_list_field_values
filter to allow filtering the List field values that will be used to populate choices. Improves compatibility with Gravity Flow!February 7, 2022: Migrated to Snippet Library.
June 24, 2014: Added support for a "sort" parameter which will sort the choices alphanumerically based on the "text" value.
January 28, 2014: Fixed issue where requiring a populated choice field failed validation unless the first option was selected.
January 2, 2014: Added example for formatting
value_template
for pricing fields.

I always have a hard time coming up with titles for snippets where the use case for something is not immediately obvious. Here’s a great use case that will help you understand the power of this handy snippet.
Let’s say you have a group activity sign-up form. You offer a variety of activities for groups but you need to know which members of the group will be participating in which activities.
This snippet can help you accomplish this by collecting the group members’ names in a List field and then populating those names in a checkbox field (or any other choice-based field) designated for each activity.
How do I get started?
- Make sure you’re running Gravity Forms v1.7.13 or later.
- Already have a license? Download Latest Gravity Forms
- Need a license? Buy Gravity Forms
- Copy and paste the snippet into your theme’s functions.php file.
- Awesome! Now you just need to configure the snippet for your Gravity form. See the usage instructions below.
Basic Usage
new GW_List_Field_As_Choices( array(
'form_id' => 1,
'list_field_id' => 2,
'choice_field_ids' => 3
) );
Enable Alphanumeric Sorting for Choices
new GW_List_Field_As_Choices( array(
'form_id' => 1,
'list_field_id' => 2,
'choice_field_ids' => 3,
'sort' => true
) );
Populate Multiple Fields
new GW_List_Field_As_Choices( array(
'form_id' => 384,
'list_field_id' => 3,
'choice_field_ids' => array( 6, 7 )
) );
Customize the Choice Label and Value
new GW_List_Field_As_Choices( array(
'form_id' => 384,
'list_field_id' => 2,
'choice_field_ids' => array( 4, 5 ),
'label_template' => '{Name} <span style="color:#999;font-style:italic;">({Age})</span>',
'value_template' => '{Name}'
) );
Auto List Field auto-syncs the number of rows in a List field with a Number or Quantity field value. It can also count the number of List field rows and use that value in Gravity Forms List field calculations.
This allows you to automatically add or subtract new List field rows based on the number value in another field!
Parameters
The form_id
, list_field_id
, and choice_field_ids
parameters are required. The snippet will fail silently; no error message is displayed.
- form_id (integer) (required) The form ID of your form.
- list_field_id (integer) (required) The field ID of the List field whose submitted values will be used to populate the choice fields.
- choice_field_ids (integer|array) (required) The field ID or fields IDs of the choice-based field(s) that will be populated from the user-entered List field values.
- label_template (string) (optional) Template used to determine how the user-entered data from the List field is used to generate the label of each choice in the choice field. Defaults to ‘{0}’. See Label Template below for more information on this.
- value_template (string) (optional) Description. Defaults to value of
label_template
parameter. See Value Template below for more information on this.
Label Template
Let’s say our List field has two columns: “Name” and “Age”. Now we’ll imagine the user has entered the following data into the list field:
David|26
Laura|27
Lee|19
The default generated choices would be:
David
Laura
Lee
Using the label_template
parameter, we can add additional user-entered data to the label. Simply use the name of the List field column to indicate which data you would like to display.
Template
'{Name}, {Age}'
Choice Labels
David, 26
Laura, 27
Lee, 19
You can also add formatting to further style and customize the choice label.
Template'{Name} ({Age})'
Choice LabelsDavid (26)
Laura (27)
Lee (19)
Value Template
The value of the choice field will default to the label unless you provide a value_template
. This parameter works in the same way as the label_template
. Having separate settings for the label and value templates allows you to have a choice label like “David (26)
” with a value like “David
“.
Value Template for Pricing Fields
If you want to populate a choice-based pricing field, you will need to format the value_template
like so:
value|price
Here is an example with actual values:
{Name}|5.25
Summary
What do you think? This is a pretty cool snippet, huh? As always, if you use it and like it, let me know!
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 47+ essential add-ons for Gravity Forms with support you can count on.
Fascinating tips, very useful and helpful.
Hi David,
Is it possible to make a list column have checkboxes to select instead of a text field?
Thanks!
Possible but problematic. I found this resource but can’t vouch for it: https://www.itsupportguides.com/knowledge-base/gravity-forms/gravity-forms-how-to-add-checkbox-option-in-list-field/
Your free snippets have helped me immensely to accomplish things my large budget competitors pay through the nose to develop. I am going to buy your perks out of sheer gratitude.
I’m really glad to hear that, Lee! Both that we’ve been a help to you and that we get to have you as a Gravity Perks customer. :)
Hi David,
This is a great snippet! Would it be used unicode column names of field list? Could you help me to modify the code to be able to use unicode in the Field list ‘label_template’ and ‘value_template’?
Thanks
Can you give me an example of what you’re trying to do?
Hi,
In your example the name of the column is {Name} and {Age} that is also the name of the column of the Field list (also the label displayed on the form). I would like to use ‘Járatszám’ as column name in the Field list, which implies to have {Járatszám} in your code as ‘label_template’ and also ‘value_template’. However, using unicode character the snippet does not work (fine with English characters). I hope it clarifies the issue that I have.
Regards, a-t-i
Ah, I see. If enough people request this, we will add support for it to the snippet. If you’d like to commission the functionality yourself, please do get in touch.
Would this snippet be able to populate to multiple form? I have a radio button field that has trip dates in it. I would like to 1. Populate the field choices from one area (either from a form field or custom post type) so the choices can be used on multiple forms with that trip date field. 2. Disable the choices after trip deadline has passed so people cannot choose those dates, deleting the choices messes up the past entries. A more advances option would be to add an expiration to each choice so that they disable on their own.
Can this snippet be used to get data from multple lists and add them to one field? Ie: I have three list fields that all have ‘Name’. I want to then get them to check if any of the ‘Names’ want a coffee. So I need to combine 3 lists into one checkbox list.
And to add to the confusion, I’d like the checkboxes to be a product/option field.
Possible?
Hi Aaron, this snippet currently only supports populating from a single List field to another single field. If you’d like to commission this enhancement, I’d love to help.
Hi. I’ve built a Team Order Portal for my client so that Team Managers can order multiple meals for their players on a single form. I used the List field with drop downs and the form uses a sticky function to present the registered user with the last order placed. Currently the meals are delivered COD.
Now my client wants to offer the option to pay for the order with a credit card. Does one of the perks allow the counting of the number of list fields in a way that can be captured by a GF field (Number?) so we can charge the client. It’s not clear to me how I can count the number of meals entered into the List field. The URL for the form is http://americanburrito.com/team-order-portal/
Thanks for your help
Hi Michael, I have this in the opposite order. You specify the number of List field rows in a Quantity field and then it will populate that many List field rows on the form.
https://gravitywiz.com/set-number-of-list-field-rows-by-field-value/
If you’d like to commission me to develop this in reverse, I’d be happy to (get in touch).
Hi David, Quite remarkable snippet here! I wonder if it’s possible to do that reversely: To populate the multiselect box or multi-dropdown values to a list field? If that’s possible, can you do that or can I hire you to achieve this function? Thanks in advance! Edi
Hey Edi, this is not currently possible. I’m interested in hearing more about how you see this working. Get in touch..
Hey David,
Would it be possible to use one column of a multiple-column list field to populate a drop-down (created using the ‘Drop Down List Field for Gravity Forms’ plugin by Adrian Gordon) inside another multiple-column list field?
Regards,
Phil Meyer (for Mike Eslick)
Hi Mike, I’m sure it’s possible but I don’t think this snippet will do the trick. Might need to hire a developer for this one.
Cool, thanks David!
Phil here though ;-)
Hey David!
I’m having a bit of an issue with this one… Essentially, the form is working fine for logged in users, but for everyone else it’s stuck on the first page.
When I tested it as admin it worked perfectly. But I’ve just had someone else try it and it just refreshes the first page of the form, instead of progressing to the second…
http://www.jonandstevewedding.com/test/
Any idea what might be going on here?
This is a great snippet that I’m sure I’ll return to in the future. Right now, unfortunately, it seems like this can’t export the checkbox values on Import/Export > Export Entries. I’ve been running into this quite a bit as a search for a way to add dynamic and variable options to a Gravity Form in a way that can export entries.
Dang, you are right. This is a limitation of this snippet. Support could be added for it but I’ll hold off until more demand is expressed. Thanks for letting me know.
Thanks for this snippet,
Got a little challenge in my usecase, how do I merge the list field with the original choice value?
For instance, I have a choice label that says : I like to go on a date with ___ I want to insert the list field in the choice label, so I have : I like to go on a date with {Name}
Kindly share how this can be achieved.
Thanks.
Hi SA, see the “label_template” property. It allows you to do this.
Hi David,
Thanks for the quick response. label_template allows me hard code the choice, yes. But, I want to merge the template choice set from the form builder.
Kindly share how to proceed with this. Thanks.
Ah, I see what you mean. This is not currently possible. If you’d like to hire me to write this customization for you, please feel free to get in touch.
Hi there!
I am wondering if it would be possible to use these values in a calculation. They do not seem to be appearing in the formula creation in the calculations box.
Thanks so much! Rosi
Could you clarify which values? The values as entered in the List field or the values populated into the choice-based field?
I want to use your brilliant snippet to dynamically populate a choice based pricing field based on a backend query that returns a “value | price” not from a list field ID.
We are using a GF hook (gform_post_render function) to send our ajax request to be queried by our custom script, and then, returned with choices with value | price values.
Do you think that’s doable?
Absolutely. Let me know if you have a specific question on implementation.
Hi There,
I’m using this extension and I’m facing a problem with my requirement. I’m using List (advanced Field Type) to add multiple input fields and radio button. I’m able to add multiple input boxes but I’m unable to add radio box along with.
For instance, please visit and you will notice that you can add more than one member using this form. https://demos.gravitywiz.com/use-list-field-as-choices-for-gravity-forms/ This allows us to populate textbox only. I have to use radio, for e.g., you are using name and age here, I need name, age, gender(using radio button).
I guess I’m clear with the requirement. Is this possible with your extension or not, if yes, then who I can do that. Any help is highly appreciated.
Many Thanks!
Hi Brij, I assume you mean that you’re converting one of the columns on the List field to use a radio button rather than a text input? If so, I would still expect this to work. Could you share an export of your form?
Hi Again,
I have another question. I have two different sponsorship types – TIC Sponsorship & Guest Sponsorship. Within each sponsorship you can choose a package – Bronze, Silver, Gold, etc. These packages cost different amounts depending on the sponsorship. Once the user picks the package, they can sign up their players and go to the next page to choose which players to add on to some extra events (at extra cost).
When I click the first first package, add my team members, and go to the next page, all the member’s names are populated and once a checkbox is clicked, the value i’ve set updates the total. However, when I click the second package (Guest), I enter team members, go the the next page, and all my team members are there but the total is not being calculated. When I check a checkbox, nothing happens. The value doesn’t seem to be passed to the “total” field.
Here’s the code i’m using: Snippet And here’s my form export: Form Export
Any help would be greatly appreciated. Thanks!
Hi Michelle, the first thing I saw is that the value template should not include a space between the value and the price:
{First Name} | $75.00
should be{First Name}|$75.00
.Hi David,
Thanks for getting back to me. I changed the value spacing as per your comment and am still getting {First Name} in my notifications. I have also set {all_fields:value} in the notification settings to try to pull that value in. Any other suggestions? Thanks again for your help!
Hi Michelle, I tried again but it’s working for me. Can you confirm if there are specific values I need to fill out (example notification)?
Thank you for this, works great! One question – In the entries and notifications from the form, I’m getting {First Name} (the value I set for the checkboxes) rather than the actual name that was entered by the user. Is there a way to change this so I can see the actual name entered?
Thanks!
Could you send me an export of your form and the ID of the specific field I should look at?
Thanks for the quick reply. Heres a link to my export Let me know if you want me to email that to you. I’m using multiple lists and checkboxes with this code so I have multiple IDs. I have conditional logic set up so a certain list shows up depending on what was chosen in a dropdown. Then on the next page, different checkbox fields will show up depending on what was chosen in that same dropdown as well.
Here’s a link to my snippet so you can see all the ids that are being called. Hopefully that’s helpful.
Thanks!
Sorry for the delay, Michelle. See if fixing the values (per my reply to your other comment) resolves this issue as well.
Hi,
I sent a reply a few days ago with links to the code you requested. Want to make sure you got it.
Thanks
Thanks David. Your snippets and perks have helped me accomplish unthinkable things in the past and I’m hoping this snippet can help me today. I have an event form. I want a user to be able to add multiple attendees via a List and checkout. Within the list, the user will select via drop-down if the attendee is a member or non-member. There is a different value for each. I would then like it to total up the attendees within the list. Can this snippet accomplish this somehow? Thanks!
Hi Shane, responded to your email on this. It’ll require a custom solution. Happy to discuss.
Your article has given me the hope that i can achieve what i want, however i dont know how.
I have this form. http://www.sydneyjewishcommunity.com.au/tehilim-signup/
In short once a user signs up and select any amount of the checkboxes on the form i would like that these checkboxes either become greyed out or hidden from the list.
I have contacted GF support and they have no snippet to achieve this. Maybe you can help me here.
It sounds like GP Limit Choices is what you’re looking for.
I’ve build a large booking-form with a list element. But there are no +/- buttons, only two underscores ( _ ) where the buttons are supposed to be.
I can’t link to the site as it is still under development (password protected), but have a look at this screenshot: http://take.ms/se0un
Also this is the code being outputted:
Why is it showing the image ‘blankspace.png’? I’ve looked in gravityforms/images, and as far as I can see, the correct files are there: add.png remove.png
Another question is how to replace these icons with either an iconfont, or svg files (for HiRes-compatibility).
Thanks.
Installed this plugin and now it works: https://github.com/wp-plugins/gravity-forms-wcag-20-form-fields
But still… why didn’t it work before?
Hi Mikkel, not sure. I tested the demo and it shows the +/- so I’m guessing you were experiencing some sort of theme or plugin conflict.