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
452fe3e3
Commit
452fe3e3
authored
Jul 01, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delay validation of scenario to validate().
parent
6c2cf9a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Model.php
framework/yii/base/Model.php
+9
-6
No files found.
framework/yii/base/Model.php
View file @
452fe3e3
...
...
@@ -249,9 +249,16 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* validation rules should be validated.
* @param boolean $clearErrors whether to call [[clearErrors()]] before performing validation
* @return boolean whether the validation is successful without any error.
* @throws InvalidParamException if the current scenario is unknown.
*/
public
function
validate
(
$attributes
=
null
,
$clearErrors
=
true
)
{
$scenarios
=
$this
->
scenarios
();
$scenario
=
$this
->
getScenario
();
if
(
!
isset
(
$scenarios
[
$scenario
]))
{
throw
new
InvalidParamException
(
"Unknown scenario:
$scenario
"
);
}
if
(
$clearErrors
)
{
$this
->
clearErrors
();
}
...
...
@@ -580,16 +587,12 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
/**
* Sets the scenario for the model.
* Note that this method does not check if the scenario exists or not.
* The method [[validate()]] will perform this check.
* @param string $value the scenario that this model is in.
* @throws InvalidParamException if the scenario to be set is unknown
* @see scenarios()
*/
public
function
setScenario
(
$value
)
{
$scenarios
=
$this
->
scenarios
();
if
(
!
isset
(
$scenarios
[
$value
]))
{
throw
new
InvalidParamException
(
"Setting unknown scenario:
$value
"
);
}
$this
->
_scenario
=
$value
;
}
...
...
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