Require All Columns of List Field

When you mark a List field as required, only one input from any column within that List is required. If you want to make all inputs required, we have a free solution.

April 26, 2022: Fixed issue where requiring specific columns did not apply to subsequent rows (again).

December 12, 2020: Fixed an issue where require list columns would fail validation if '0' is submitted.

July 14, 2015: Fixed issue where requiring specific columns did not apply to subsequent rows.

January 7, 2015: Added support any field with an input type of List field; this provides support for using this snippet with Post Custom Fields with an input type of List.

September 13th, 2012: Updated to use a class format to allow you to apply this functionality to a specific form and/or specific fields.

October 22, 2013: Updated to support a $require_columns parameter. Allows requiring specific columns rather than all columns on a list field.

When you mark a List field as required, only a single input from any column is required. What if you want every input in every column to be required? Here is a snippet that let’s you do it.

How do I install this snippet?

Just copy and paste the code above in your theme’s ”functions.php” file.

Do I need to configure this snippet to work with my form(s)?

Require All Columns on All Forms

Only if you want to apply this functionality to specific forms and/or specific fields. A default instantiation of this class (with no parameters) will apply this functionality to all list fields on all forms.

new GWRequireListColumns();

Require All Columns on a Specific Form

To apply this to a specific form, you would simply pass the form ID as the first parameter:

new GWRequireListColumns(4);

Require All Columns on a Specific Field

To apply this functionality to a specific form and a specific List field on that form, you would specify the form ID as the first parameter and the field ID as the second:

new GWRequireListColumns(4, 2);

Require All Columns on a Group of Fields

To apply this functionality to a specific form and multiple List fields on that form, you would specify the form ID as the first parameter and an array of fields IDs as the second parameter:

new GWRequireListColumns(4, array(2,3) );

Require Specific Columns on a Group of Fields

To require specific columns on a specific field, you would specific the form ID, the field ID and the specific columns (by index, starting with 1) you would like to require:

new GWRequireListColumns( 240, 1, array( 2, 3 ) );

Note: If you have used new GWRequireListColumns() to require all columns on all fields, you can override which columns are required for a specific field by passing the $require_columns parameter in a new instance of this class.

Did you know that you can automatically add new List field rows to your forms based on the numbers entered in another field? Gravity Forms 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 can be conveniently used in combination with the Set Number of List Field Rows by Field Value snippet.


  1. Natalie
    Natalie March 6, 2023 at 9:56 am

    Has this been tested with GravityKit’s GravityView plugin? This works fine when submitting a form however we’ve found it doesn’t enforce the required setting when the user chooses to edit the entry in GravityView.

    1. David Smith
      David Smith Staff March 7, 2023 at 3:08 pm

      Hey Natalie, I confirmed that this is working in GravityView:

      It’s possible something else is conflicting?

  2. Dan J
    Dan J October 13, 2022 at 2:51 pm

    Sorry, this just isn’t working for me, but maybe I’m not using it correctly. Do I need to add a “GWRequireListColumns” class to the form or the fields themselves? Or do I need a GravityWiz plugin or account before this works? Just putting this code in my functions.php file has no effect.

  3. John K
    John K April 22, 2022 at 3:30 pm

    May I suggest you put this “Leave a Reply” section at the top of the comments? And shouldn’t it be named “Leave a Comment”? Reply to what? And your submit button says “Post Comment”. I didn’t think I could post a new comment because I couldn’t imagine having to scroll to the very bottom of what could have been an extremely long list of comments.

    Or at least post a link to this section at the top of the comments.

    Also, I have checked to receive emails from followup comments but I’ve never received one. There’s nothing in my Spam folder either.


    1. Scott Ryer
      Scott Ryer Staff April 22, 2022 at 4:30 pm

      Hi John,

      Thanks for the feedback. I’m going to share it with our developers.

      I just tested the comment emails, and emails are arriving in my inbox. I suggest reaching out to your email provider about this.

  4. Dario Space
    Dario Space August 17, 2021 at 11:24 am

    Hi Vinod,

    This looks like a question that will require some digging.

    If you have an active Gravity Perks License, can you please get in touch with us via our support form with your account email address so we can assist you further.


  5. Alexis
    Alexis January 6, 2020 at 6:37 am

    Hello ! Very nice snippet but the validation works only on the first row. If i add another row i can go to the next step of my form without filling fields of the second row while it’s required.

    Do you have an idea of what could be the problem ?

    Thank’s a lot for your snippet !

    1. John
      John April 21, 2022 at 9:29 pm

      The Demo doesn’t work properly either. The Player’s field only needs the first row of required fields filled. Aside from all columns instances, this only works on the first row for me as well.

    2. Samuel Bassah
      Samuel Bassah Staff April 22, 2022 at 4:50 am

      Hi John,

      You sent in multiple comments with the same issue so we approved one. That said, I’m unable to recreate the issue you’re reporting. I just tested the demo and it works correctly. The required columns work on every row and not just the first row. The player list field has the first, second and fourth column as required so the configuration will be something like so: new GWRequireListColumns( 123, 4, array( 1, 2, 4 ) );

      You can get in touch with us via our support form if you have an active Gravity Perks license, so we can take a look at your setup and assist you to set it up.


    3. John K
      John K April 22, 2022 at 11:34 am

      I’ve replied multiple times yet none of them show up. Are they being rejected?

      The Demo doesn’t work the same way the snippet doesn’t work for anything but all columns. For a specific column(s) it only works for the first row. Any response?

    4. John K
      John K April 22, 2022 at 12:02 pm

      I apologize for submitting another duplicate reply. I only see my replies after I submit a reply. Even after I refresh the page I don’t see them so I post another.

      Did you fill out the demo as follows? All Coach fields in all rows filled in. It only works if all fields filled in. Only 1st row of multiple Player rows are filled in for fields 1, 2, 4.

      If the first Player row is not filled in as described then i correctly get the validation error. But I can fill in that row and leave all the other rows empty and submit successfully.

      This mirrors what happens on my site. How do you track multiple rows of data? Do you get/need the length of the list?

      It’s easy to validate everything. It seems there’s a bug when there are specific fields in multiple rows.

      How can the Demo work differently for different people?

    5. Dario Space
      Dario Space April 22, 2022 at 12:30 pm

      Hi John,

      It seems to work on the demo page when testing with the data you provide and when testing locally. You can get in touch with us via our support form if you have an active Gravity Perks license, so we can take a look at your setup and assist you to set it up.


    6. John K
      John K April 22, 2022 at 1:14 pm

      Dario, that’s the point: it should NOT work with the data I provided. Shouldn’t it fail validation if ALL Player rows are not filled in for inputs 1, 2, 4?

      What do you mean by “it works”, that it submits successfully with empty Player rows or fails validation with empty Player rows?


    7. Samuel Bassah
      Samuel Bassah Staff April 22, 2022 at 1:22 pm

      Hi John,

      We’ve finally been able to recreate the issue with the demo and snippet. I’ll pass this over to our developers to dig into it. We’ll update the comment section when this is resolved.


    8. John K
      John K April 23, 2022 at 11:12 am

      The release note at the top of this article says:

      “July 14, 2015: Fixed issue where requiring specific columns did not apply to subsequent rows.”

      That was 7 years ago. This seems to be the very issue we’re discussing. Was this fix undone by futures fixes or did this fix ever actually work?


    9. Samuel Bassah
      Samuel Bassah Staff April 25, 2022 at 5:36 am

      Hi John,

      Yes, it appears to be the same issue that was fixed but that was in 2015 and over the years, Gravity Forms has evolved. I’m guessing one of the recent Gravity Forms versions may have broken the code. This has been forwarded to our developers to look into. We’ll update the comment and release note to let everyone know when the issue is resolved.


    1. David Smith
      David Smith Staff November 15, 2019 at 1:43 pm

      This is very similar to a recent issue reported by one of our Gravity Perks customers with this snippet. Here is our response to him:

      After digging in, it turns out this really isn’t something we can fix on our end; however, I did find a simple solution. Just use this JS snippet to automatically select the first choice of each drop down when a new row is added.

      If you need a good way to add form-specific Javascript like this, check out our free plugin:

  6. Chris
    Chris November 5, 2019 at 12:23 am

    Works like magic, but i have two limitations or issues with it.

    1. The code is too long, i prefer something shorter and simple.

    2. The error message highlights all the whole lists, instead of highlighting the affected rows, or colums only. And it can be very tasking for a list of over 250 rows.

    1. David Smith
      David Smith Staff November 5, 2019 at 7:38 am

      Thanks for the feedback, Chris. The code is as long as it needs to be to meet the requirements. As for the highlighting the affected rows/columns, this is feasible but would require some considerable customization as Gravity Forms only provides field-level validation but not row-level. We’ll monitor demand for such an enhancement. 🙂

  7. Joel Newcomer
    Joel Newcomer July 11, 2019 at 2:04 pm

    Hi! I am using this on a website and it had been working fine to my knowledge but the client requested that one column not be required so I used the code to require specific columns, but it doesn’t seem to be working. Users are now able to submit with an entirely blank row. Any ideas? Here is my code:

    new GWRequireListColumns(2, 7, array( 1, 2, 3 ) );

    and here is an example form:

    Thank you!


    1. Joel Newcomer
      Joel Newcomer July 18, 2019 at 8:23 am

      I see that it is working in the demo and I believe I resolved the issue. I believe the code on the website was an older version of this. I updated that and I believe that fixed it. Thanks David!

  8. Sandy
    Sandy October 8, 2018 at 3:58 pm

    Can you please help sort out this issue? I’m getting an error after submitting my form:

    Warning: Invalid argument supplied for foreach() in /home/jcres/public_html/processes/wp-content/plugins/process-functionality-plugin/functionality-plugin.php on line 852

    The code on line 852 is:

    foreach($values as $value) { if(empty($value)) { $new_validation_error = true; $field[‘failed_validation’] = true; $field[‘validation_message’] = $field[‘errorMessage’] ? $field[‘errorMessage’] : ‘All inputs must be filled out.’; } }

  9. Jeremy
    Jeremy April 20, 2018 at 12:45 pm

    Hello David, We have a list that has almost 200 rows; is there a way to have it actually highlight the row that is actually failing validation?

    1. Jeremy
      Jeremy April 20, 2018 at 4:36 pm

      Thanks, I tackled from the client side after all. Glad to see you added support for the List Fields.

  10. Moshtaghi
    Moshtaghi November 26, 2017 at 8:17 am

    Hello and thanks I copy this code to functions.php of my theme and use new GWRequireListColumns(); but it doesn’t work. None of the fields are required. please help me

  11. Brijesh
    Brijesh November 19, 2017 at 9:45 am


    I am trying this snippet on my website but it seems to break the website. I pasted the code in functions.php and the site goes blank. Appreciate any help.

  12. joe
    joe February 20, 2017 at 8:59 am

    Thanks for this code! Seems to trip up when there is more than one list on the form and the required-rules are different for each.

    Can you help me make this work?

    eg – List 1 needs columns 1, 2 & 3 as mandatory – List 2 needs columns 1, 4 & 5 as mandatory


  13. james
    james January 21, 2017 at 3:42 am

    Hi there,

    I’ve installed the code from the download link to the functions file, and am utilizing the “Require Specific Columns on a Group of Fields”. It’s not working for me. Do I need to comment out the other classes or how can I get this to work?

    It’s on the “select product type” field and first checkbox “roller shade”

    password is: matiss.

    Not to worry this is only a test form. THanks!

    1. David Smith
      David Smith Staff January 21, 2017 at 8:32 am

      Hi James, you’ll need to enable the Required setting for this field in the form editor field settings as well.

  14. Justin McDonald
    Justin McDonald January 10, 2017 at 10:56 pm

    Hi David, This doesn’t seem to work when the Save & Continue Button is used. If you access the form via the Resume link the fields are no longer mandatory.


  15. Blake
    Blake May 27, 2016 at 10:49 am


    Thank you for providing the code to accomplish this! One issue I’m running into is whenever I add this code and submit a form without all the list columns filled in, I get a “jQuery is not defined” console error, which messes up some jQuery code I have on the form. This console error is not there before submitting the form.

    The form validation works perfectly, just curious what could be causing this console error to appear after submitting the form.

    Any idea of why this may be happening?

    Thanks again!!

    1. Blake
      Blake May 31, 2016 at 10:15 am

      Hey David,

      Here is a link to the form:

      If you scroll down, choose the “PDF Version” option then “Click Here to Order”. After that, click the “I have read and agree to the terms and conditions.” and the Checkout button should appear.

      If you try to submit the form without filling out all the fields, the Terms and Conditions opens up and I’m getting the “jQuery is not defined”. I’m using another plugin called Collapse-O-Matic ( for the Terms and Conditions accordion function.

      If the issue is the Collapse-O-Matic plugin, I can figure out a different route, I just wanted to make sure it was nothing with the code I added to require all list fields.

      Thanks for looking into this!

    2. David Smith
      David Smith Staff June 30, 2016 at 12:29 pm

      Hi Blake, sorry for the long wait. I see the issue and yes this is generated by the snippet + AJAX enabled forms. I’m going to hold off on addressing this for now but if more people are attempting to use this in the same way, I will revisit.

  16. Sulayman Khan
    Sulayman Khan May 23, 2016 at 9:55 pm

    I am having an issue where when I use this snippet along with the “Set Number of List Field Rows by Field Value”.

    When I change the quantity field to 0, there is still one list item showing. The problem is that it is showing a validation error because the field is marked as required.

    I have uploaded an example of the issue I am having:

    How can I get this scenario handled? Any help would be appreciated.

    1. David Smith
      David Smith Staff May 24, 2016 at 8:55 am

      Hi Sulayman, I would use conditional logic to hide the field if quantity is less than 1. If the Quantity field is not available for selection in conditional logic, you can add a Number field, enable calculations and set the merge tag for the quantity field as the formula. This will essentially “copy” the value to the Number field and then you can base your conditional logic rule on the Number field.

  17. Eduardo
    Eduardo November 6, 2015 at 2:22 pm

    Wow, thanks for the code!

    But, I have one question: how would you validate the email fields in the demo page?

    Again, good work :-)

    1. David Smith
      David Smith Staff November 22, 2015 at 6:07 pm

      Hi Eduardo, they actually aren’t validated to ensure they’re actually email addresses. Just that they are not empty.

  18. Chris
    Chris August 12, 2015 at 6:53 am

    Fantastic! This has long been a bugbear of Gravity Forms for me. One addition I would like to see is custom validation feedback messages. For example, if I have set only certain columns as required, I would prefer to say customise the feedback rather than ‘All inputs must be filled out.’, as this is not the case in this instance.

    Thank you! :)

  19. Ore B
    Ore B July 14, 2015 at 5:19 am

    Hello David

    I recently tried to require certain columns only and it only works on the first row. The ‘require’ rules fail to apply on subsequent rows

    I looked through the comments and it seemed this had been addressed.

    however here’s the address

    Below is the code at the end of snippet: // require specific field columns on a specific form new GWRequireListColumns( 1, 1, array( 1, 3, 4, 5 ) );

    I appreciate your help on this


    Ore B

    1. David Smith
      David Smith Staff July 14, 2015 at 10:28 am

      Thanks for letting me know, Ore. I’ve just updated the snippet to fix this error. You can get grab the latest code above.

  20. Mikkel Hansen
    Mikkel Hansen June 24, 2015 at 7:35 am

    How do I translate the validation message?

    I am using WPML, but as far as I see in the code above, the validation message string won’t get recognized by WPML’s string translation module?


    1. David Smith
      David Smith Staff June 24, 2015 at 12:32 pm

      Hm, not sure on this one Mikkel. It might be possible to add this to WPML but I don’t believe WPML will automatically pick it up. They’re support would have a much better answer on this. If you could do me a favor and let me know, I’d be interested in any solution you come up with.

    2. Mikkel Hansen
      Mikkel Hansen June 26, 2015 at 8:34 am

      I will try to reach out to WPML team and see if they have a quick solution.

      In the meantime I noticed something strange happening when I have the code in my functions.php. It breaks the grid view of the media manager. I have no idea why or how, but no images are being loaded in the media manager when the library_mode is set to grid. This also means I cannot add images to my posts/pages as the insert media window apparently uses the grid view.

      Removing your code from functions.php solves the problem.

      Could you investigate?

    3. David Smith
      David Smith Staff June 26, 2015 at 10:48 am

      Hi Mikkel, this code is running on my local server and on the demo server. I checked and I’m able to access the media manager without issue. I think there may be some other issue or conflict causing this on your end.

      I would try two things:

      1. Confirm you have installed the snippet correct:
      2. Run a theme/plugin conflict:
  21. Andrei G
    Andrei G May 1, 2015 at 10:54 am


    Thank you for this great snippet. It seems to do the trick just fine, but only if all columns of the list have regular single line text inputs.

    In my case, I have one of the columns as a dropdown select menu (you can override using gform_column_input filter), and it validates OK even if nothing is selected in the dropdown.

    Any ideas how to fix this?

    Thanks again.

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

      Hi Andrei, I’ve added a drop down input to the List field on the demo and it appears to limit correctly. Could you make sure you’re getting the code via the “Download Code” button? I’ve also cleared the cache on this post in case there was any out-of-date code being displayed.

  22. Masoud Ahmadzada
    Masoud Ahmadzada March 16, 2015 at 5:40 pm

    How can I use this in combination with the Set number of list field rows by value field snippet, so that all columns and all rows are required?

    1. David Smith
      David Smith Staff March 16, 2015 at 5:44 pm

      Does it not work by just including both snippets? I wouldn’t think you’d need to do anything fancy.

    2. Masoud Ahmadzada
      Masoud Ahmadzada March 16, 2015 at 7:03 pm

      I thought it would work as well. I looked on the net and it seems that input fields that are added dynamically after the page load are not added to the $_POST variable. Otherwise the 2nd, 3rd, etc. rows have the same name attribute as the original first row input field. One solution I found was that I would need to add my own submit handler that uses jquery $.post to send to the php script manually.

    3. Masoud Ahmadzada
      Masoud Ahmadzada March 16, 2015 at 7:04 pm

      But I’m not sure exactly about how to go about doing that as my knowledge of gravity forms internals is somewhat limited.

    4. Masoud Ahmadzada
      Masoud Ahmadzada March 17, 2015 at 9:33 pm

      Yes, you were right. I had modified your code somewhat and it turned out that modification was causing the problem. It now works as intended, which is great. Thank you!

  23. Angela Bendall
    Angela Bendall November 29, 2014 at 3:41 pm

    Hi, Using the snippet above along with snippet “Set Number of List Field Rows by Field Value”, I have:

    1. a multi-page form
    2. a list field on page 2 of my form set to display a repeating number of rows based on a quantity on page 1 of my form.
    3. the list field on page 2 of my form has 4 columns, 2 of which are mandatory.

    The snippet for “Set Number of List Field Rows by Field Value” seems to be working perfectly.

    However, the snippet to validate only specific columns seems to have an issue whereby only the first row seems to be being validated; basically, testing on row 1 is perfect, but for rows 2, 3, 4 etc., there does not seem to be any validation and I am able to go on to the next page of the form.

    In my functions file, I’ve called the snippet above as: new GWRequireListColumns( 13, 246, array( 1, 2 ) );

    Unfortunately, my site is currently in ‘coming soon mode’, but I would be happy to PM you a username.

    Many thanks in advance for any help you can offer! Angela

  24. Doug Regehr
    Doug Regehr July 8, 2014 at 12:46 pm

    Found a small issue. When using a Custom Field that acts as a List, I needed to change the is_applicable_field function to look at the InputType and not the Type. Here is my new function.

    function is_applicable_field($field, $form) {
                if($field['pageNumber'] != GFFormDisplay::get_source_page($form['id']))
                    return false;
                //change to inputType from Type
                if($field['inputType'] != 'list' || RGFormsModel::is_field_hidden($form, $field, array()))
                    return false;
                // if the field has already failed validation, we don't need to fail it again
                if(!$field['isRequired'] || $field['failed_validation'])
                    return false;
                    return true;
                return in_array($field['id'], $this->field_ids);
  25. Joakim Ekendahl
    Joakim Ekendahl November 13, 2013 at 7:06 am

    Hi David, thanks for a great snippet! I have a problem with using the class for making a single column required. It seems that the form validates by just entering data in this column for the first row. Is it possible to make only the first column required on each row of the list?

  26. Jon
    Jon October 25, 2013 at 3:21 pm

    I am sure that the error is on me but I just can’t figure this out. I have copy/pasted the class into my functions.php. I have not change anything (I do plan on limiting to specific fields but just for testing left it alone) and I am not seeing any effect at all. I have tried adding the call to the class (new GWRequireListColumns();) within the page template that the form is displayed on. I am not sure what I am missing here. Any suggestion are greatly appreciated.

    1. Jon
      Jon October 25, 2013 at 3:32 pm

      Nothing like a check box to halt all development. My apologies my guys said they tested that way as well. Your snippet is great.

  27. Eddy Pareja
    Eddy Pareja October 8, 2013 at 2:08 pm

    David, Very cool! I’m looking for almost this exaclty. I think I can modify it to do what I need, which is to specifically designate particular columns as required or optional. I’m thinking if I just add a parameter to the class construct (array for the indexes of the required colums) that when it comes time to loop through the values, I can instead check only the indexes passed (if any were). That seems like it should work aye? Am I missing anything? I do that sometimes :P

    1. David Smith
      David Smith Staff October 8, 2013 at 7:04 pm

      Hey Eddy, if I were doing this, I’d do exactly that. If you end up modifying this snippet to handle it, I’ve love to update the code here as well. :)

    2. Eddy Pareja
      Eddy Pareja October 17, 2013 at 10:43 pm

      David, Ok, I modified your awesome class to accept a 3rd parameter in the construct. Just like the form field parameter, a single value or array will do. If this parameter is detected instead of looping through all the field values, require_list_columns() loops through only the values who’s indexes are in the array. I’ve tested it pretty thoroughly and the logic seems sound. If any of my syntax is goofy or inefficient I’m sure you can whip it into shape. Here it is.. and thanks again for the huge head start on this!

    3. David Smith
      David Smith Staff October 22, 2013 at 7:13 am

      Awesome stuff, Eddy! I’ve modified the code just a bit to support being able to apply the GWRequireListColumns class globally and then overriding with required columns for specific fields. You can see the latest here:

      Do you have a website or twitter I can give a shoutout too?

      EDIT: Also, I updated it to allow users to enter “1” for column “0”, “2” for “1” etc as I thought this would be less confusing for non-developer users.

  28. waqas
    waqas December 18, 2012 at 6:30 am

    I have tried this code and i found one thing missing, this code gives error when there is list field on second page break or third page break of the form.

    For example, if you have multi page form and your list field is on first page of the multi page form then it works fine, but if list field is on second page of multi page form then it starts generating error of values not filled out.

    Is there any solution to that?


    1. David Smith
      David Smith Staff December 19, 2012 at 12:31 pm

      Hi Waqas, I’ve updated the snippet to fix this issue. Grab the latest code and let me know if you run into anything else. :)

    2. waqas
      waqas December 20, 2012 at 2:16 am

      Hi David, Thanks for quick help. yes really it solved the issue. Now the snippet is working fine on multi page form.


    1. David Smith
      David Smith Staff December 11, 2012 at 2:16 pm

      Hi Shahzad, one thing that might be confusing is that this snippet simply enhances the “Required” field setting ( for list fields to require all columns rather than just the first input. You will still need to check the “Required” option to require this field after installing the snippet.

  29. Raoni
    Raoni September 17, 2012 at 8:21 pm

    Hi! That’s nice!!! I found just one problem….. In my form I have a Conditional to show the List Field. Even if the List FIeld do not show in the forms is asking to input something. Could you help me please?

    1. David Smith
      David Smith Staff September 18, 2012 at 6:36 am

      Hi Raoni, I’ve updated the snippet to include support for conditional logic. List fields hidden by conditional logic will no longer be validated by this functionality. :)

    1. David Smith
      David Smith Staff September 13, 2012 at 6:23 pm

      Hi Raoni, I’ve just updated the snippet to include support for this. The code changed pretty significantly so I would delete what you copied before and grab the latest snippet above. :)

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

Require All Columns of List Field

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