我在一個名爲add.ctp的視圖中輸入字段有問題。當輸入類型設置爲「文本」時,程序順序是正常的。但是,當我將輸入類型更改爲'隱藏'時,會顯示以下錯誤:cakephp隱藏字段問題
The request has ben black-holed. Error: The requested address was not found on this server.
mod-rewrite似乎已激活。任何想法,這可能是什麼原因?
我在一個名爲add.ctp的視圖中輸入字段有問題。當輸入類型設置爲「文本」時,程序順序是正常的。但是,當我將輸入類型更改爲'隱藏'時,會顯示以下錯誤:cakephp隱藏字段問題
The request has ben black-holed. Error: The requested address was not found on this server.
mod-rewrite似乎已激活。任何想法,這可能是什麼原因?
這意味着您的代碼有錯誤。以下是如何創建隱藏文本框
echo $this->Form->input('field_name', array('type'=>'hidden'));
代碼沒有錯誤。 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');
我想這是因爲你使用SecurityComponent。
組件監視表單完整性,隱藏字段不應該從用戶更改,因爲安全組件「決定」已經用例如CSRF攻擊形式進行惡意的事情,並且它阻止提交。我相信你有一些JavaScript會由於某種原因改變字段值。
直指點! –