free hit counter

Remove Cakephp Model Field Validation from Controller

 

Remove Cakephp Model Field Validation from Controller

Remove Cakephp Model Field Validation from Controller

in Cakephp we set all validation in model ! but many time we didn’t need some validation for particular field !
in that condition  how to remove that validation ?

its very simple , you need to write some line in controller

 

  1. //Remove only Single Rule of a field   
  2.   
  3. $this->User->validator()->remove(‘phone’‘rule1′);  
  4.    
  5. //Completely remove all validation rules of  a field   
  6.   
  7. $this->User->validator()->remove(‘phone’);  

 

First Line of code will remove only the rule1 of  phone field

Second line of code will remove all Validation of phone field .

Leave a Reply