Use List Field As Choices for Gravity Forms

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.

gw-list-field-as-choices

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?

  1. Make sure you’re running Gravity Forms v1.7.13 or later.
  2. Copy and paste the snippet into your theme’s functions.php file.
  3. 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}'
) );

Combine this functionality with Gravity Forms Auto List Field!

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 Labels
David (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!

Comments

    1. Dario
      Dario Staff June 19, 2023 at 11:15 am

      Hi James, this will require some digging about your use case. If you have an active Gravity Perks license, you can contact us via our support form so that we can ask some additional information and look into this further.

  1. Oxana
    Oxana July 11, 2021 at 3:54 pm

    Hi David,

    The snippet works with checkboxes, but what if I want to pass the label and value of the selected radio button, how to modify the code?

    Reply
    1. Dario Space
      Dario Space Staff July 12, 2021 at 11:16 am

      Hi Oxana,

      We have a Perk that allows you to copy values between fields: Gravity Forms Copy Cat. If you have an active Gravity Perks License, you can open a ticket with us via our support form, with your account email so that our developers can take a look into it.

      Best,

  2. Nebil
    Nebil March 22, 2021 at 3:50 am

    Hi David, How to adapt this code to populate the checkbox options from another checkbox instead of a list. The checked boxes from the first chekbox are the values for the second one. Thank you for your help

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff March 22, 2021 at 8:52 am

      Hi Nebil,

      If the first checkbox field will be in another form entry, we have a snippet that works with GP Populate Anything to make it possible to use that Checkbox field choices as choices for the second checkbox field.

      However, if both Checkbox fields will be on the same form, then I’m guessing this other tutorial of ours with a similar setup should work for you. In that tutorial, replacing the survey field with a checkbox field should populate the second checkbox field with the choices checked in the first checkbox field.

      Best, Best,

    1. Scott Ryer
      Scott Ryer Staff May 31, 2022 at 2:23 pm

      Hi Bhaskarjyoti,

      The configuration for Drop Down fields is identical to any other choice-based field. Put the List field on any page previous to the one that includes the Drop Down, and update the parameters in the snippet to reflect the form ID, List field ID, and Drop Down field ID.

  3. abdo
    abdo March 18, 2020 at 4:34 pm

    Hi David, I like this solution,

    I want to do the same things but i didn’t understand when i change “list_field” to other field, the code didn’t work me. please give me any suggestion. Thank you.

    Reply
    1. Ryan Donovan
      Ryan Donovan March 19, 2020 at 9:37 am

      Hello there, could you please let us know how you configured the snippet? The best way for us to view that is to send a snippi link including your snippet setup. If you need help troubleshooting the snippet, go ahead and check out this help article. Let us know! 😀

  4. Jasper
    Jasper November 1, 2019 at 11:09 am

    Hi all,

    Does anybody know how to adjust this perk to make it work with the gravity survey ranks field? I would like to achieve that the elements of the list can be ranked, not only checked, with the rank survey field.

    Many thanks in advance! Jasper

    Reply
    1. David Smith
      David Smith Staff November 4, 2019 at 7:56 am

      This is a little tricky as Survey fields have special values that are generated to uniquely identify each choice. Certainly possible but something you’d likely need to hire a developer to achieve.

  5. Quang D
    Quang D September 25, 2018 at 6:22 am

    Hi David,

    Is there a premium version of this snippet, where users can use a UI to set up for each form instead of messing with functions.php?

    If there isn’t, is there a plan on developing one?

    Please let me know. Thank you!

    Reply
    1. David Smith
      David Smith Staff September 25, 2018 at 8:19 am

      Hi Quang, there is no premium version currently; however, we do have plans to add support for this in another upcoming perk. No definite ETA but if you’d like, I can add you to the notification list for that perk. ?

  6. Andre Nell
    Andre Nell March 20, 2018 at 1:58 pm

    Hi David, I love gravity perks. I have been a subscriber for a few years now.

    I have a question about this free perk.

    I have two identical forms with one exception. One form has read only fields whereas the second form can only be accessed by admin and those same fields are editable.

    Do I need to make a duplicate of the code I have included with the new form_id or do I just add the form_id to the existing function.

    ‘form)_id’ => 27,45,

    Reply
  7. Lee
    Lee May 12, 2017 at 2:42 pm

    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.

    Reply
    1. David Smith
      David Smith Staff May 13, 2017 at 11:15 am

      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. :)

  8. a-t-i
    a-t-i April 30, 2017 at 4:44 am

    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

    Reply
    1. a-t-i
      a-t-i April 30, 2017 at 11:41 am

      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

    2. David Smith
      David Smith Staff May 1, 2017 at 9:12 am

      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.

  9. Sam Mitzmann
    Sam Mitzmann February 9, 2017 at 4:11 pm

    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.

    Reply
  10. aaron
    aaron January 19, 2017 at 11:42 am

    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?

    Reply
  11. michael loewenberg
    michael loewenberg September 16, 2016 at 3:00 pm

    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

    Reply
  12. Edi Michael
    Edi Michael April 18, 2016 at 7:54 am

    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

    Reply
  13. Mike Eslick
    Mike Eslick March 30, 2016 at 4:04 pm

    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)

    Reply
    1. David Smith
      David Smith Staff March 30, 2016 at 7:08 pm

      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.

  14. Jon Watson
    Jon Watson January 23, 2016 at 4:58 pm

    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?

    Reply
  15. Mark Root-Wiley
    Mark Root-Wiley December 31, 2015 at 12:11 pm

    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.

    Reply
    1. David Smith
      David Smith Staff March 14, 2016 at 8:24 pm

      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.

  16. SA
    SA November 26, 2015 at 7:07 am

    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.

    Reply
    1. SA
      SA November 26, 2015 at 8:43 am

      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.

  17. Rose
    Rose October 26, 2015 at 1:24 pm

    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

    Reply
    1. David Smith
      David Smith Staff October 26, 2015 at 9:06 pm

      Could you clarify which values? The values as entered in the List field or the values populated into the choice-based field?

  18. TM
    TM October 14, 2015 at 6:23 pm

    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?

    Reply
  19. Brij Raj Singh
    Brij Raj Singh September 17, 2015 at 9:47 am

    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!

    Reply
    1. David Smith
      David Smith Staff September 19, 2015 at 7:30 pm

      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?

  20. Michelle
    Michelle September 1, 2015 at 2:25 pm

    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!

    Reply
    1. David Smith
      David Smith Staff September 8, 2015 at 12:31 am

      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.

    2. Michelle
      Michelle September 15, 2015 at 12:02 pm

      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!

  21. Michelle
    Michelle August 26, 2015 at 5:30 pm

    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!

    Reply
    1. Michelle
      Michelle August 27, 2015 at 12:59 pm

      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!

    2. David Smith
      David Smith Staff September 8, 2015 at 1:35 am

      Sorry for the delay, Michelle. See if fixing the values (per my reply to your other comment) resolves this issue as well.

    3. Michelle
      Michelle August 31, 2015 at 3:50 pm

      Hi,

      I sent a reply a few days ago with links to the code you requested. Want to make sure you got it.

      Thanks

  22. Shane Richardson
    Shane Richardson July 1, 2015 at 12:52 pm

    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!

    Reply
    1. David Smith
      David Smith Staff July 3, 2015 at 12:20 am

      Hi Shane, responded to your email on this. It’ll require a custom solution. Happy to discuss.

  23. Ilan
    Ilan May 31, 2015 at 9:17 pm

    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.

    Reply
  24. Mikkel
    Mikkel May 12, 2015 at 4:17 am

    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.

    Reply
    1. David Smith
      David Smith Staff May 12, 2015 at 11:05 am

      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.

  25. flo
    flo May 1, 2015 at 1:29 pm

    Hi David, any chance to populate a select field (with enhanced interface) on another form with those values? List values from field #3 in form id 10 shall populate select field #17 in form 21. That would be very nice! Flo

    Reply
    1. David Smith
      David Smith Staff May 2, 2015 at 8:26 pm

      Hi Flo, this might be possible by passing the data from the List field via the URL to the second form. You could then populate the data from the URL into a List field on the second form (optionally hidden via the gf_hidden class). Then you could use this snippet to populate the select on the second form.

  26. Lars
    Lars April 24, 2015 at 9:37 am

    Hi David,

    This is an awesome snippet, lots of usecases for this one.

    One question though, which I cannot seem to wrap my own brain around answering.

    Is it possible to “reverse” the output on page 2 of the form, so that for example “David | 26” becomes to title and “Ski Lessons: Who is attending?” becomes the choice?

    Imagine that it instead said “Ski lesson 1”, or “Advanced ski lesson” or something else that would make more sense.

    Thanks in advance.

    Reply
  27. Adlan Khalidi
    Adlan Khalidi March 2, 2015 at 3:05 am

    Hi.

    I’d like to know if I want to make a simple list field like that. By default showing 1 field, then if user click ‘+’ it will add another line.

    But I don’t want to use this as choices.

    Thanks.

    Reply
    1. David Smith
      David Smith Staff March 2, 2015 at 4:39 pm

      Hi Adlan, this is possible with Gravity Forms “List” field, available under the “Advanced Fields” field group.

  28. Cosmin M.
    Cosmin M. October 27, 2014 at 4:11 am

    Hi David Smith , can you tell me please how you added the button Add another row / Remove this row on demo page? Search this feature for a long time to use with gravity form.

    Reply
  29. playmo
    playmo October 21, 2014 at 1:33 pm

    That’s great! very good work, I’m trying to do quite the same but I’m able I would like to to divide the process in two step. At the beginning of the year I use a form to insert a list of classroom: 1A, 2C, 5E, 3B and so on During the year I need to use it a lot of times in a lot of different form Can you please help me in this? Thank you very much in advance :)

    Reply
    1. David Smith
      David Smith Staff October 21, 2014 at 2:10 pm

      Hi playmo, this is not currently possible with this snippet and would require a decent bit of customization to implement.

  30. Herb
    Herb July 30, 2014 at 4:22 pm

    Excellent solution. Thank you! Is there a way to set the values of ‘form_id’, ‘list_field_id’, and ‘input_html_id’ to a variable so we do not have to enter a new array in functions.php for each form? Thanks!

    Reply
    1. David Smith
      David Smith Staff July 30, 2014 at 7:51 pm

      Not currently. If this functionality proves popular enough it will be created as a perk with a UI so you could activate from the form editor. If this is something you need and would like to sponsor the development, please do get in touch.

  31. Soubarna Das
    Soubarna Das July 1, 2014 at 2:09 pm

    Inspired by your work I am trying to do it in a reverse way. From a dropdown choice to text field. I try to get the dropdown value with

    $drop_field = GFFormsModel::get_field( $form, 2 ); $idtest = GFFormsModel::get_field_value( $drop_field );

    But with no success. Could you please tell me how do I fetch the dropdown choice? Thanks in advance.

    Reply
  32. webdev
    webdev June 23, 2014 at 1:03 pm

    thanks for all your information and education on gravity forms! i have just started using these on my site and am amazed at how powerful this tool is!

    i had one quick question about sorting, in this example how would your sort this by age, and then by name?

    i am working on a site with a large database of names and need an easier way to sort for users to find their name, but am having issues.

    thanks so much!

    Reply
    1. David Smith
      David Smith Staff June 24, 2014 at 7:50 am

      Hi webdev, I’ve just updated the snippet to support a new “sort” parameter which will sort the choices alphanumerically based on the “text” value. A usage example has been added to the article above.

  33. BlackGnat
    BlackGnat May 30, 2014 at 6:28 am

    Hi great snippet of code which we have working up to the point of gathering the data once the form’s submitted. We have changed the code to populate a select instead of a checkbox. The select gets populated ok but the selected value does not get sent to the server. Is there something obvious to edit in the code for the select menu value to be sent?

    Reply
    1. David Smith
      David Smith Staff May 30, 2014 at 6:17 pm

      Hi BlackGnat, sent you an email with a request for more details. I’ve been unable to recreate this issue on my end.

  34. Ryan McGraw
    Ryan McGraw May 26, 2014 at 10:17 am

    Hi,

    Can you help me with this? I am having problems with the select menus…

    We’ve checked the docs for implementing the dynamic population of a select menu at https://gravitywiz.com/use-list-field-choices-gravity-forms/. We can get a select menu populated ok but the value doesn’t get sent as part of the $entry.

    1. We’ve set up the constructor of the GW_List_Field_As_Choices class thus..

    function __construct( $args ) { $this->_args = wp_parse_args( $args, array( ‘form_id’ => false, ‘list_field_id’ => false, ‘choice_field_ids’ => false, ‘label_template’ => ‘{Name}’, //corresponding to field label name ‘value_template’ => ‘{Name}’ //redundant as label is default value

    ) );

    1. We’ve modified the populator of the ‘select’ menu thus…

    if( GFFormsModel::get_input_type( $field ) == ‘select’ ) { $inputs = array(); foreach( $choices as $index => $choice ) { $inputs[] = array( ‘label’ => $choice[‘text’], ‘id’ => $field[‘id’] . ‘.’ . ( $index + 1 ) ); } $field[‘inputs’] = $inputs; }

    1. We’re applying the dynamic population to multiple select menus in the form…

    new GW_List_Field_As_Choices( array( ‘form_id’ => 15, ‘list_field_id’ => 213, ‘choice_field_ids’ => array(225,243,252) ) );

    All the select menus are populated but they do not send a value when the form is submitted. Have looked and looked but cannot see a reason. We could supply whole code base if necessary but sure it can only be a small issue that we cannot see.

    Reply
    1. David Smith
      David Smith Staff May 30, 2014 at 6:29 pm

      Hi Ryan, just sent you an email requesting more details. I have not been able to recreate this locally.

  35. Mike Muller
    Mike Muller April 29, 2014 at 4:34 pm

    Hi David,

    Do you have any specifics on how to set up the form fields in the GF admin? I’m tyring to get the code to work and have not been successful. Do I need to check the “Populate Dynamically” checkbox in the admin?

    Reply
  36. Mike Muller
    Mike Muller April 29, 2014 at 4:24 pm

    Hi David,

    I’m trying to implement the code and something’s not working correctly. Do you have any specifics on how the form needs to be set up in Gravity Forms? Does the “Populate Dynamically” option need to be checked on the choice field?

    Thanks in advance.

    Reply
  37. Ashley Freedman
    Ashley Freedman April 28, 2014 at 3:47 pm

    Hi David,

    The form export isn’t showing the dynamic population- there’s just many, many blank columns. How can we have their selection show up? Blank columns kind of defeat the purpose in economizing our registration process with dynamic population.

    Thanks, Ashley

    Reply
  38. Joshua M
    Joshua M April 25, 2014 at 2:47 pm

    Forget I asked about multi-page forms. Looks like it was an incomplete HTML tag which took a long time to find, but has nothing to do with the snippet. Sorry to bug you!

    Reply
  39. Stephen Barrett
    Stephen Barrett April 9, 2014 at 2:20 pm

    Hi! I love your snippets. They have been a tremendous help to me.

    I was wondering if there was a way to combine two different lists to be shown in one multiple choice field? I see that you can put the list into two multiple choice fields, but can you do it the other way around? Making the list_field_id an array.

    Reply
    1. David Smith
      David Smith Staff April 10, 2014 at 8:45 am

      Hi Stephen, it is possible but would require a modification of the “populate_choice_fields” method. Currently it only looks for a single list field, gets the values for that field and populates it. You would need to update this to loop through the array of list fields and get all the values for each field.

      If you’d like to commission me to make this modification, get in touch!

  40. Stephen
    Stephen April 3, 2014 at 11:05 am

    I love this snippet. This is what I am looking for, but I was wondering if I have to have multiple pages to the form to populate the checkbox fields or can the checkbox fields be further down the form and it automatically fills when I get to it on the form.

    Reply
  41. Stephen
    Stephen April 2, 2014 at 7:49 pm

    Is there a way to have snippet to populate the checkbox field that is further down the page? Or does the form have to have a multiple page setup?

    Reply
  42. walad7bab
    walad7bab January 25, 2014 at 4:56 pm

    Many thanks for all your efforts here. You are a great talent.

    I was planning to use this like a mini shopping cart. The action plan is; I get my customer to list the items they want to order (the list field auto populate using jquery as customer types in) the auto populate function would also insert a price in one of the rows and customer just adds the quantity required.

    Your code, or a modified version of it, would create products and prices automatically for payment purposes.

    Could this be possible or not?

    Sample Scenario A customer has a prescription to fill and this prescription has multiple medications. For this person to work out the cost of this prescription he would need to list each item along with the quantity required.

    Then the form would workout the total cost then charge the patient.

    Reply
  43. Corbin
    Corbin January 23, 2014 at 11:07 am

    This is a great solution! Thanks!

    I needed something almost exactly like this. The only issue I came across with using this was that if you’re charging for attendance to additional events/seminars, the product choices don’t appear to add up per checkbox. Not really an issue with this script, moreso with how Gravity Forms operates. If there was a way to add the options together that would be great – ie

    Event name (Product field) John Doe | ($30.00) Jane Doe | ($30.00) Hank Hill | ($30.00)

    Then total it up to $90.00

    In the mean time I think the best solution for my scenario is to just have the user re-type names attending events by adding an extra Quantity field + List combo, described in: https://gravitywiz.com/set-number-of-list-field-rows-by-field-value/

    Thanks again for the tremendous insights you share with the Gravity Forms community!

    Reply
    1. David Smith
      David Smith Staff January 23, 2014 at 10:57 pm

      Hi Corbin, I actually think we can pull this off. The trick is to use an Option field (instead of Product field since Checkbox input type is not supported).

      Then you’ll need to use a value template like this: “{Name}|30” changing “30” to whatever price each attendee should cost and “{Name}” to whatever the label of the desired column to display is (use “{0}” if you only have a single column on your List field). Here’s what my config looks like.

      That should give you something like this. Let me know if you have any questions on getting this setup. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Snippet

Use List Field As Choices for Gravity Forms

This field is for validation purposes and should be left unchanged.