2014-02-08 127 views
1

我在一个名为add.ctp的视图中输入字段有问题。当输入类型设置为“文本”时,程序顺序是正常的。但是,当我将输入类型更改为'隐藏'时,会显示以下错误:cakephp隐藏字段问题

The request has ben black-holed. Error: The requested address was not found on this server.

mod-rewrite似乎已激活。任何想法,这可能是什么原因?

回答

0

这意味着您的代码有错误。以下是如何创建隐藏文本框

echo $this->Form->input('field_name', array('type'=>'hidden')); 
3

代码没有错误。 CakePHP's Security component检查隐藏表单域,以防止终端用户篡改:

By default SecurityComponent prevents users from tampering with forms. It does this by working with FormHelper and tracking which files are in a form. It also keeps track of the values of hidden input elements. All of this data is combined and turned into a hash. When a form is submitted, SecurityComponent will use the POST data to build the same structure and compare the hash.

使用FormHelper::unlockField做出领域从此功能豁免:

$this->Form->unlockField('User.id'); 
+0

直指点! –

0

我想这是因为你使用SecurityComponent。

组件监视表单完整性,隐藏字段不应该从用户更改,因为安全组件“决定”已经用例如CSRF攻击形式进行恶意的事情,并且它阻止提交。我相信你有一些JavaScript会由于某种原因改变字段值。