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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
ed98df5c
Commit
ed98df5c
authored
Nov 22, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed broken UniqueValidator
parent
6995e8dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
UniqueValidator.php
framework/yii/validators/UniqueValidator.php
+3
-3
No files found.
framework/yii/validators/UniqueValidator.php
View file @
ed98df5c
...
...
@@ -65,12 +65,12 @@ class UniqueValidator extends Validator
$attributeName
=
$this
->
attributeName
===
null
?
$attribute
:
$this
->
attributeName
;
$attributes
=
$className
::
attributes
();
if
(
!
in_array
(
$attribute
,
$attributes
))
{
if
(
!
in_array
(
$attribute
Name
,
$attributes
))
{
throw
new
InvalidConfigException
(
"'
$className
' does not have an attribute named '
$attributeName
'."
);
}
$query
=
$className
::
find
();
$query
->
where
([
$attribute
=>
$value
]);
$query
->
where
([
$attribute
Name
=>
$value
]);
if
(
!
$object
instanceof
ActiveRecord
||
$object
->
getIsNewRecord
())
{
// if current $object isn't in the database yet then it's OK just to call exists()
...
...
@@ -82,7 +82,7 @@ class UniqueValidator extends Validator
$n
=
count
(
$objects
);
if
(
$n
===
1
)
{
if
(
in_array
(
$attribute
,
$className
::
primaryKey
()))
{
if
(
in_array
(
$attribute
Name
,
$className
::
primaryKey
()))
{
// primary key is modified and not unique
$exists
=
$object
->
getOldPrimaryKey
()
!=
$object
->
getPrimaryKey
();
}
else
{
...
...
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