您好,我有以下型号:
class Mymodel extends AppModel {
public $validate = array(
'username' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A username is required'
),
'regexp' => array(
'rule' => '/^[a-z0-9]{3,10}$/i',
'message' => 'Only letters and integers, min 3, max. 10 characters'
)
)
)
}
和以下视图:signup.ctp
<?php
echo $this->Form->create("Mymodel ");
echo $this->Form->input('username' ,array('label'=>"Username :"));
echo $this->Form->input('password' ,array('label'=>"Password :",'type' => 'password'));
echo $this->Form->end('signup');
?>
我的控制器是:
class MymodelController extends AppController
{
public function signup()
{}
}
cakePHP 默认验证行为是在输入下方显示错误消息,所以我的问题是:如何在标签字段中显示错误我的意思是这样的:
用户名:(我想在这里显示错误信息)