我想为我的web应用程序创建一个登录表单。
即使我使用$validate
阵列,也不会显示表单验证errros。CakePHP不显示我的表单错误
user.php的
public $validate = array(
'email' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'notEmpty',
'required' => true
),
'isEmail' => array(
'rule' => 'email'
),
'isUnique' => array(
'rule' => 'isUnique'
)
),
'password' => array(
'notEmpty' => array(
'rule' => 'notEmpty'
),
'minLength' => array(
'rule' => array('minLength', 8)
)
)
);
我看不到我的用户模型中的错误,所以我会告诉你我的控制器和我的观点。
users_controller.php中
class UsersController extends AppController {
public $name = 'Users';
public $helpers = array(
'Form'
);
public function login() {
if(!empty($this->data)) {
if ($this->Auth->user() != null) {
$this->Session->setFlash('You are now logged in.', 'flash/success');
$this->redirect('/');
} else {
$this->Session->setFlash('You could not get logged in. Please see errors below.', 'flash/error');
}
}
}
login.ctp
echo $this->Form->create('User', array('action' => 'login'));
echo $this->Form->input('User.email', array(
'label' => __('email address:', true),
'error' => array(
'notEmpty' => __('Email address must not be blank.', true),
'isEmail' => __('Email address must be valid.', true),
)
));
echo $this->Form->input('User.password', array('label' => __('password:', true)));
echo $this->Form->end('Log in');
我希望你能帮助我。几小时后我找不到我的错误。是否有可能需要包含组件或助手?
好的,谢谢!是否可以停用登录表单的这些必需符号? – mhmpl
需要什么符号? –
使用默认布局和css文件,CakePHP添加红色星号(*)符号。 – mhmpl