Model view controller 在CakePHP 2中包含一个组件

Model view controller 在CakePHP 2中包含一个组件,model-view-controller,controller,components,cakephp-2.0,Model View Controller,Controller,Components,Cakephp 2.0,我试图在cakephp2.0的Controller中使用Security组件,但我做了一些错误的事情 我已经阅读了,但是当我在我的控制器中包含安全组件并调用控制器操作寄存器时,我会得到一个空白页。如果我注释includepublic$components=array('Security')它又起作用了,我错在哪里 <?php App::uses('CakeEmail', 'Network/Email'); class UsersController extends AppControlle

我试图在
cakephp2.0
Controller
中使用
Security
组件,但我做了一些错误的事情

我已经阅读了,但是当我在我的
控制器中包含
安全
组件
并调用控制器操作
寄存器
时,我会得到一个
空白页
。如果我注释include
public$components=array('Security')它又起作用了,我错在哪里

<?php
App::uses('CakeEmail', 'Network/Email');
class UsersController extends AppController {
    public $components = array('Security');

    public function register () {
        if (!empty($this->data)) {
            if ($this->data['User']['password'] == $this->data['User']['confirm_password']) {
                $this->User->create();
                $this->User->save($this->data);
                $this->registrationEmail ($this->data['User']['email'], $this->data['User']['username']);
                $this->redirect(array('controller'=>'users', 'action'=>'registration', 'success'));
            }
        }
    }
    private function registrationEmail ($account_email, $username) {
        $email = new CakeEmail('myconfig');
        $email->from(array('mailer@email.com' => 'MySite.com'));
        $email->to($account_email);
        $email->subject('Account activation / MySite.com');
        $email->template('activation');
        // $this->set('activation_code', Security->hash($account_email));
        $email->viewVars(
            array(
                'activation_code' => $this->Security->hash($account_email),
                'username' => $username
            )
        );
        $email->send();
    }
?>

注册表在视图文件中是如何呈现的

如果您使用的是安全组件,则需要使用FormHelper生成所有表单字段。此外,一旦FormHelper给了隐藏值一个值,就不能在前端处理隐藏值