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
e990be93
Commit
e990be93
authored
Jan 05, 2014
by
Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1788 info about retaining the default scenario
parent
3eaf0021
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
model.md
docs/guide/model.md
+15
-0
No files found.
docs/guide/model.md
View file @
e990be93
...
...
@@ -112,6 +112,21 @@ class User extends \yii\db\ActiveRecord
}
```
If you want to keep the default scenario available besides your own scenarios, use inheritance to include it:
```
php
class
User
extends
\yii\db\ActiveRecord
{
public
function
scenarios
()
{
$scenarios
=
parent
::
scenarios
();
$scenarios
[
'login'
]
=
[
'username'
,
'password'
];
$scenarios
[
'register'
]
=
[
'username'
,
'email'
,
'password'
];
return
$scenarios
;
}
}
```
Sometimes, we want to mark an attribute as not safe for massive assignment (but we still want the attribute to be validated).
We may do so by prefixing an exclamation character to the attribute name when declaring it in
`scenarios()`
. For example:
...
...
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