Disable form security CakePHP
Asked Answered
C

2

6

Is it possible to turn of all CakePHP security features for only 1 particular form in a view? So I don't get any hidden fields (tokens) in that form.

Thank you,

Bart

Concordant answered 12/6, 2012 at 19:11 Comment(0)
H
3

You can disable it for that action via:

public function beforeFilter() {
    parent::beforeFilter();
    if ($this->request->params['action'] == 'action') { 
        $this->Security->validatePost = false; 
    } 
}
Holocaust answered 12/6, 2012 at 21:1 Comment(0)
H
0

In order to remove annoying hidden inputs _Token.key and fields from your form (for instance, to clarify query string when you use GET method), you need to do following stuff on beforeRender in addition to beforeFilter from tigrang's answer:

function beforeRender() {
    parent::beforeRender();
    unset($this->params["_Token"]);
}

(This is actual at least for CakePHP 1.3)

Hereditament answered 17/7, 2012 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.