Community

How do I disable validation that runs on an AJAX callback?

I'm implementing the ajax "add more" functionality to a Drupal form. Basically, the user can enter a variable number of records into the form. So, there's an 'add more' button which when click is supposed to show an additional row in the form. I've got this working. The problem is that when I set a field in the form to be required, And the user has left it blank, the new row doesn't appear. Rather validation errors appear. I want the validation, of course, but I don't want it firing on the ajax callback. I've searched throughout and found nothing. How do I disable this validation that runs on an AJAX callback?

Comments

limit_validation_errors()

I think you can use limit_validation_errors().