March 31, 2021: Migrated snippet to the Snippet Library.
July 27, 2020: Fixed issue where script could be run before jQuery was loaded.
April 25, 2020: Added compatibility for the GravityView Edit Entry screen.
August 22, 2019: Fixed intermittent issue where loading script in Gravity Forms Gutenberg block caused Parent Selector to disappear.
October 5, 2013: Updated snippet to use a class format for easier instantiation which also adds support for applying to multiple forms and multiple fields on the same form.
January 26, 2013: Updated to better select the current list field table rows.
Found this interesting question on the Gravity Forms forum:
I’m selling tickets. So each ticket needs to be associated with a name/email/etc…
Basically, the user needs a way to gather a set of data per ordered product/ticket. My first instinct was to simply recommend using the List field. The user could specify the number of tickets and then add/remove however many rows they need.
I kept thinking on it and realized it would be really nice if the number of List field rows increased/decreased automatically based on the number of selected tickets. Here’s a snippet to do just that!
How do I install this snippet?
Just copy and paste the snippet above into your theme’s functions.php file.
Do I need to modify this snippet to work with my form?
You just need to create your own instance of the
GWAutoListFieldRows class. You’ll find two examples at the bottom of the snippet. Comment them out and then add your own! All you need to set is the
$list_field_id, and the HTML id of your input as the