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
8c8a3898
Commit
8c8a3898
authored
Jun 17, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3772: Behaviors adding validation rules do not work as expected
parent
a252622d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Model.php
framework/base/Model.php
+9
-7
No files found.
framework/CHANGELOG.md
View file @
8c8a3898
...
@@ -44,6 +44,7 @@ Yii Framework 2 Change Log
...
@@ -44,6 +44,7 @@ Yii Framework 2 Change Log
-
Bug #3751: Fixed postgreSQL schema data for enum values, do not add values if there are none (makroxyz)
-
Bug #3751: Fixed postgreSQL schema data for enum values, do not add values if there are none (makroxyz)
-
Bug #3752:
`QueryBuilder::batchInsert()`
does not typecast input values (qiangxue)
-
Bug #3752:
`QueryBuilder::batchInsert()`
does not typecast input values (qiangxue)
-
Bug #3756: Fix number formatting error for
`\yii\base\Formatter`
by converting strings to float (kartik-v)
-
Bug #3756: Fix number formatting error for
`\yii\base\Formatter`
by converting strings to float (kartik-v)
-
Bug #3772: Behaviors adding validation rules do not work as expected (qiangxue)
-
Bug #3817:
`yii\rbac\PhpManager::getChildren()`
returns null instead of expected empty array (qiangxue)
-
Bug #3817:
`yii\rbac\PhpManager::getChildren()`
returns null instead of expected empty array (qiangxue)
-
Bug #3843: Fixed Menu bug when using
`template`
with
`encodeLabel`
=> false (creocoder, umneeq)
-
Bug #3843: Fixed Menu bug when using
`template`
with
`encodeLabel`
=> false (creocoder, umneeq)
-
Bug #3863: Fixed incorrect js selector for
`\yii\widgets\ActiveForm::errorSummaryCssClass`
when it contains multiple classes (creocoder, umneeq)
-
Bug #3863: Fixed incorrect js selector for
`\yii\widgets\ActiveForm::errorSummaryCssClass`
when it contains multiple classes (creocoder, umneeq)
...
...
framework/base/Model.php
View file @
8c8a3898
...
@@ -310,19 +310,24 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -310,19 +310,24 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
*/
*/
public
function
validate
(
$attributeNames
=
null
,
$clearErrors
=
true
)
public
function
validate
(
$attributeNames
=
null
,
$clearErrors
=
true
)
{
{
if
(
$clearErrors
)
{
$this
->
clearErrors
();
}
if
(
!
$this
->
beforeValidate
())
{
return
false
;
}
$scenarios
=
$this
->
scenarios
();
$scenarios
=
$this
->
scenarios
();
$scenario
=
$this
->
getScenario
();
$scenario
=
$this
->
getScenario
();
if
(
!
isset
(
$scenarios
[
$scenario
]))
{
if
(
!
isset
(
$scenarios
[
$scenario
]))
{
throw
new
InvalidParamException
(
"Unknown scenario:
$scenario
"
);
throw
new
InvalidParamException
(
"Unknown scenario:
$scenario
"
);
}
}
if
(
$clearErrors
)
{
$this
->
clearErrors
();
}
if
(
$attributeNames
===
null
)
{
if
(
$attributeNames
===
null
)
{
$attributeNames
=
$this
->
activeAttributes
();
$attributeNames
=
$this
->
activeAttributes
();
}
}
if
(
$this
->
beforeValidate
())
{
foreach
(
$this
->
getActiveValidators
()
as
$validator
)
{
foreach
(
$this
->
getActiveValidators
()
as
$validator
)
{
$validator
->
validateAttributes
(
$this
,
$attributeNames
);
$validator
->
validateAttributes
(
$this
,
$attributeNames
);
}
}
...
@@ -331,9 +336,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -331,9 +336,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
return
!
$this
->
hasErrors
();
return
!
$this
->
hasErrors
();
}
}
return
false
;
}
/**
/**
* This method is invoked before validation starts.
* This method is invoked before validation starts.
* The default implementation raises a `beforeValidate` event.
* The default implementation raises a `beforeValidate` event.
...
...
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