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
96918665
Commit
96918665
authored
Jan 05, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1789 from docsolver/patch-2
Info about retaining the default scenario
parents
3eaf0021
e990be93
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 @
96918665
...
...
@@ -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