用户模型
//...
public $validate = array(
"username" => array(
"alpha-numeric" => array(
'rule' => 'alphaNumeric',
'required' => true,
'message' => 'Username must contain only numbers and letters.'
),
"between" => array(
"rule" => array("between", 4, 25),
"message" => "Username must contain between 4 to 25 characters."
)
),
//...
用户控制器
public function index() {
debug($this->data); // displays values as expected
debug($this->User->validates()); // always false, unless I remove alphanumeric rule
}
提交时,username
无论文本中包含什么内容,我的表单都会始终将该字段验证为 false(触发其相应的消息)。其余字段也未验证。如果我username
一起删除验证规则,其余字段仍未验证。(提交表格如同经过验证)
我在这里想念什么?