Securityコンポーネントを使用すると自動的に付加されるはずのtokenが生成されません。
(Securityコンポーネントが効いていません)
cakeのバージョンは2.5.4です。
保存ボタンでpostすると、blackholeメソッドに飛ばされます。
書籍、ネット等調べましたが、なぜかわかりません。お願いします。
【View】
<?php echo ($this->Form->create(array( 'type' => 'post', 'url' => array('controller' => 'コントローラー名', 'action' => 'formtest') ))); echo ($this->Form->submit('保存')); echo ($this->Form->end()); ?>【出力】
<form action="/コントローラー/formtest" id="コントローラーForm" method="post" accept-charset="utf-8"> <div style="display:none;"> <input type="hidden" name="_method" value="POST"> </div> <div class="submit"> <input type="submit" value="保存"> </div> </form>lang
1【コントローラーでの記述】 2public $components = array('Cookie','Security'); 3 4public function beforeFilter() { 5 parent::beforeFilter(); 6 (Cookieの設定を記述)...略 7 // $this->Security->requirePost('formtest'); 8 // $this->Security->requireAuth('formtest'); 9 10public function formtest(){ 11 $this ->layout =''; 12 echo 'Hello World'; 13 $this->autoRender = false; 14 } 15
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。