Drupal multi-step forms

#limit_validation_errors

We just recently had to build a new form for an web page. Cause this form is divided in question and personal details section we used the possibility of multi-step forms in Drupal. The form should also provide a back button and here we come to our problem.

The Form API offers to set the property #limit_validation_errors on submit button. If you set the value to an empty array, the validation of the form will be bypassed completely and we can achieve our back button functionality.

"This is normally used in multistep forms in the case of a "back" button, for example, where '#limit_validation_errors' => array() would mean not to validate anything as form values on the current page are to be discarded anyway."

Sadly enough we had to try around a while until we figured out that this isn't true for the form element of the type radios. For no reason, the validation is still fired if you have such an element in your form with the property #required set to be true.

We haven't found no work around other than setting the element to be optional.

Tags: 
Drupal 7
radios
multi-step