1

I am building a multi-step form. For one of the steps, I have some required fields. When the user goes back, I'm skipping the validation, but it gets hung up on my required fields. Is there a way to disable or ignore my required fields so my user can go back a step?

1

Yes, you can use

#limit_validation_errors

Used by: button, image_button, submit

Description: Provides an array of sections which are parts of $form_state['values'] which should be validated, implying that sections which are not listed should not be validated.

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.

#limit_validation_errors does not have any effect if #submit is not set. More discussion is in the form_set_error() documentation.

Values: array indicating sections of the $form_state['values'] which should be validated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.