Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f3450682
Commit
f3450682
authored
Dec 29, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1689 from Ragazzo/controller_docs
csrf docs added
parents
e16c4858
b0351ba4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
controller.md
docs/guide/controller.md
+38
-0
No files found.
docs/guide/controller.md
View file @
f3450682
...
...
@@ -39,6 +39,44 @@ The output of an action is what the method returns. The return value will be han
component which can convert the output to differnet formats such as JSON for example. The default behavior
is to output the value unchanged though.
You also can disable CSRF validation per controller and/or action, by setting its property:
```
php
namespace
app\controllers
;
use
yii\web\Controller
;
class
SiteController
extends
Controller
{
public
$enableCsrfValidation
=
false
;
public
function
actionIndex
()
{
#CSRF validation will no be applied on this and other actions
}
}
```
To disable CSRF validation per custom actions you can do:
```
php
namespace
app\controllers
;
use
yii\web\Controller
;
class
SiteController
extends
Controller
{
public
function
beforeAction
(
$action
)
{
// ...set `$this->enableCsrfValidation` here based on some conditions...
// call parent method that will check CSRF if such property is true.
return
parent
::
beforeAction
(
$action
);
}
}
```
Routes
------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment