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
4e7421d6
Commit
4e7421d6
authored
Dec 12, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #6505
parent
481e4803
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
14 deletions
+5
-14
input-validation.md
docs/guide/input-validation.md
+5
-14
No files found.
docs/guide/input-validation.md
View file @
4e7421d6
...
@@ -22,15 +22,6 @@ if ($model->validate()) {
...
@@ -22,15 +22,6 @@ if ($model->validate()) {
}
}
```
```
Behind the scenes, the
`validate()`
method does the following steps to perform validation:
1.
Determine which attributes should be validated by getting the attribute list from
[
[yii\base\Model::scenarios()
]
]
using the current
[
[yii\base\Model::scenario|scenario
]
]. These attributes are called
*active attributes*
.
2.
Determine which validation rules should be used by getting the rule list from
[
[yii\base\Model::rules()
]
]
using the current
[
[yii\base\Model::scenario|scenario
]
]. These rules are called
*active rules*
.
3.
Use each active rule to validate each active attribute associated with that rule. If the rule fails,
keep an error message for the attribute in the model.
## Declaring Rules <a name="declaring-rules"></a>
## Declaring Rules <a name="declaring-rules"></a>
...
@@ -92,13 +83,13 @@ If you do not specify an `on` option, it means the rule will be applied to all s
...
@@ -92,13 +83,13 @@ If you do not specify an `on` option, it means the rule will be applied to all s
When the
`validate()`
method is called, it does the following steps to perform validation:
When the
`validate()`
method is called, it does the following steps to perform validation:
1.
Determine which attributes should be validated by
checking the current
[
[yii\base\Model::scenario|scenario
]
]
1.
Determine which attributes should be validated by
getting the attribute list from
[
[yii\base\Model::scenarios()
]
]
against the scenarios declared in
[
[yii\base\Model::scenarios()
]
]. These attributes are the active attributes
.
using the current
[
[yii\base\Model::scenario|scenario
]
]. These attributes are called
*active attributes*
.
2.
Determine which
rules should be applied by checking the current
[
[yii\base\Model::scenario|scenario
]
]
2.
Determine which
validation rules should be used by getting the rule list from
[
[yii\base\Model::rules()
]
]
against the rules declared in
[
[yii\base\Model::rules()
]
]. These rules are the active rules
.
using the current
[
[yii\base\Model::scenario|scenario
]
]. These rules are called
*active rules*
.
3.
Use each active rule to validate each active attribute which is associated with the rule.
3.
Use each active rule to validate each active attribute which is associated with the rule.
The validation rules are evaluated in the order they are listed.
The validation rules are evaluated in the order they are listed.
According to the above validation steps, an attribute will be validated if and only if it is
According to the above validation steps, an attribute will be validated if and only if it is
an active attribute declared in
`scenarios()`
and is associated with one or multiple active rules
an active attribute declared in
`scenarios()`
and is associated with one or multiple active rules
declared in
`rules()`
.
declared in
`rules()`
.
...
...
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