How to validate single field of a model in cakephp
问题 I have a model called User and its $validate has 39 field validations and working fine in UsersController. In another controller I need to use the same code and validate only a single field from controller. Can Someonce please help me with this? 回答1: Relevant docs. Use the fieldList option in the model's validates() method. $this->ModelName->set($this->data); if ($this->ModelName->validates(array('fieldList' => array('myField')))) { // If myField validated successfully... } 来源: https:/