Reputation: 6353
Is there a way to call multiple rule sets (The rule sets are in a config file). Such as:
$this->form_validation->run('contact_info', 'billing_info')
That way I can update a form including all of those rule sets, or just one of those rule sets. If this isn't possible, what is my alternative besides creating a new "merged" rule set. Would I just have to run the validation twice?
Upvotes: 2
Views: 669
Reputation: 3148
hey i just did this for the first time yesterday ! yeah just call the validation twice, once for each set of rules. its pretty cool actually - because like in this example - you can make a custom error message for contact and for billing.
with a model named: tigercats
if ( $this->tigercats->_validateContact() == FALSE ) {
$this->formerrormessage = 'Not enough fur in contact' ;
$this->_showValidationFailed() ; }
elseif ( $this->tigercats->_validateBilling() == FALSE ) {
$this->formerrormessage = 'Claws missing in billing' ;
$this->_showValidationFailed() ; }
else { $this->_showHappyTigersGetPaid() ; }
and obviously you can just run validation twice in a more compressed way if you dont need custom messages.
Upvotes: 3
Reputation: 539
"the way codeigniter is setup doesn't lend itself to allow you to validate with multiple rules, you can extend the form helper with a function to group rules" I think that should help you out, and this.
Upvotes: -1