Forms CakePHP表单篡改

Forms CakePHP表单篡改,forms,cakephp,cakephp-2.0,Forms,Cakephp,Cakephp 2.0,我用CakePHP2制作的表单有问题 表单提交很好,但后来我改变了它,现在我也提交了一些其他的东西。我还这样做,用户可以选择他要提交的“服务”的数量 现在,表单仅在存在exactley 1“服务”时提交。 我认为问题在于“表单篡改”保护。 既然我希望用户“篡改”表单,我如何禁用此保护 我的beforeFilter如下所示: parent::beforeFilter(); $this->Auth->allow('register_new'); // Security

我用CakePHP2制作的表单有问题

表单提交很好,但后来我改变了它,现在我也提交了一些其他的东西。我还这样做,用户可以选择他要提交的“服务”的数量

现在,表单仅在存在exactley 1“服务”时提交。 我认为问题在于“表单篡改”保护。 既然我希望用户“篡改”表单,我如何禁用此保护

我的beforeFilter如下所示:

parent::beforeFilter();

    $this->Auth->allow('register_new');

    // Security component
    if (isset($this->Security) &&
        $this->RequestHandler->isAjax() &&
        ($this->action == 'statistics'))
    {
        // $this->Security->validatePost = false;
        $this->Security->csrfCheck = false;
    }

    if (isset($this->Security) &&
        $this->RequestHandler->isAjax() &&
        ($this->action == 'markPaid'))
    {
        $this->Security->validatePost = false;
        $this->Security->csrfCheck = false;
    }
问题中的“操作”(没有获取任何数据的操作)是“注册新的”。

代码

$this->Auth->allow('register_new');
使
register\u new
无需身份验证即可访问,但不会禁用表单篡改保护

if($this->request->params['action'] == 'register_new')
{
    $this->Security->validatePost = false;
}
或者,您也可以仅通过使用禁用某些字段的后期验证

$this->Security->unlockedFields = array('field_1', ...);
这样做的好处是可以对其他人进行验证