I have a form 开发者_如何学JAVAin my add_note action, where I do not want SecurityComponent to put its tokens or checking. How do I do this?
I have tried requireAuth('some_other_action') etc. but it doesn't work.
In CakePhp 2.3 do:
$this->Security->unlockedActions= array('add_note');
Original answer for CakePHP 1.2 to 2.2.x:
public function beforeFilter() {
    if (isset($this->Security) && $this->action == 'add_note') {
        $this->Security->validatePost = false;
    }
}
Updated answer for CakePHP 2.3+ and 3.x (as pointed out in the other answer):
public function beforeFilter(Event $event)
{
     $this->Security->config('unlockedActions', ['add_note']);
}
Also, it's possible to unlock specific fields (as pointed out in the comments)
$this->Form->unlockField('Note.id');
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论