Ralph
Ralph

Reputation: 11

Multi step form validation Codeigniter

Is it possible in Codeigniter to run a multi-step Form validation, such that, when an error has been found, the form validation will stop (not validating the other Form validation rules)?

With the set_rules() and run() method of the Form_validation class, all the rules are checked even if it does not pass the first one.

Or is it better to validate those criteria in my model in the particular order (such that it stops on a validation error) and pass the single error message to my view?

Upvotes: 1

Views: 838

Answers (1)

Aidas
Aidas

Reputation: 1249

Ralph, I am not sure you can do it with standard CI validation library.. You may need to extend/overwrite it in order to achieve what you want. You can display a first error message individually, but in the background the full data check would run. Depending on how complex the data validation you need, you could also get some jQuery plugin to roughly check the data before the form is submitted. This will reduce the risk of bad data being sent and may reduce the overhead on server side.

Upvotes: 0

Related Questions