Validation in controller of CakePHP using inbuilt model functions

This are the ways through which one can use model functions in the controller to validate forms. This should be used in rare conditions only.


Example:

1. if(!Validation::email($this->data['MerchantRedeemForm']['email'], true)) {
       $this->MerchantRedeemForm->validationErrors['email'] = 'Please enter a valid email.';
}


2. if(!Validation::url($this->data['MerchantRedeemForm']['url'], true)) {
       $this->MerchantRedeemForm->validationErrors['url'] = 'Please enter a valid url.';
}



Comments

Post a Comment