我有一个模型login
- 它有5个字段。在注册时,我正在验证所有字段,但是当我编辑记录时,我只想在保存数据之前验证一些字段。表单验证在cakephp
我使用这个代码:
if ($this->Login->validates(array('fieldList' => array('password','name')))) {
if ($this->Login->save($this->data)) {
echo 'helllo';exit;
//$this->Session->setFlash('Your post has been updated.');
//$this->redirect(array('action' => 'profile'));
}else {
}
} else {
}
但它不工作。
它因为我使用主键someid代替id。 – p27 2011-05-27 06:34:37
@ p27然后告诉Cake:http://book.cakephp.org/view/1061/primaryKey – deceze 2011-05-27 06:36:18
感谢您的好建议。 – p27 2011-05-27 08:59:54