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
de63a46d
Commit
de63a46d
authored
Sep 10, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4984.
parent
b604bc56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
UPGRADE.md
framework/UPGRADE.md
+1
-2
yii.activeForm.js
framework/assets/yii.activeForm.js
+11
-7
No files found.
framework/UPGRADE.md
View file @
de63a46d
...
...
@@ -256,8 +256,7 @@ new ones save the following code as `convert.php` that should be placed in the s
} elseif (attribute.id === 'something') {
// the event is triggered before validating "something"
}
// if you want to cancel the validation, do the following:
// event.isValid = false;
// if you want to cancel the validation, return a boolean false.
});
```
framework/assets/yii.activeForm.js
View file @
de63a46d
...
...
@@ -28,7 +28,7 @@
* The signature of the event handler should be:
* function (event, messages, deferreds, attribute)
* where
* - event: an Event object.
You can set event.isValid to be false to stop validating the form or attribute
* - event: an Event object.
* - messages: error messages. When attribute is undefined, this parameter is an associative array
* with keys being attribute IDs and values being error messages for the corresponding attributes.
* When attribute is given, this parameter is an array of the error messages for that attribute.
...
...
@@ -36,6 +36,8 @@
* - attribute: an attribute object. Please refer to attributeDefaults for the structure.
* If this is undefined, it means the event is triggered before validating the whole form.
* Otherwise it means the event is triggered before validating the specified attribute.
*
* If the handler returns a boolean false, it will stop further validation after this event.
*/
beforeValidate
:
'beforeValidate'
,
/**
...
...
@@ -58,6 +60,8 @@
* The signature of the event handler should be:
* function (event)
* where event is an Event object.
*
* If the handler returns a boolean false, it will stop further validation after this event.
*/
beforeSubmit
:
'beforeSubmit'
,
/**
...
...
@@ -237,9 +241,9 @@
deferreds
=
deferredArray
();
if
(
data
.
submitting
)
{
var
event
=
$
.
Event
(
events
.
beforeValidate
,
{
'isValid'
:
true
}
);
var
event
=
$
.
Event
(
events
.
beforeValidate
);
$form
.
trigger
(
event
,
[
messages
,
deferreds
]);
if
(
!
event
.
isValid
)
{
if
(
event
.
result
===
false
)
{
data
.
submitting
=
false
;
return
;
}
...
...
@@ -254,9 +258,9 @@
msg
=
[];
messages
[
this
.
id
]
=
msg
;
}
var
event
=
$
.
Event
(
events
.
beforeValidate
,
{
'isValid'
:
true
}
);
var
event
=
$
.
Event
(
events
.
beforeValidate
);
$form
.
trigger
(
event
,
[
msg
,
deferreds
,
this
]);
if
(
event
.
isValid
)
{
if
(
event
.
result
!==
false
)
{
if
(
this
.
validate
)
{
this
.
validate
(
this
,
getValue
(
$form
,
this
),
msg
,
deferreds
);
}
...
...
@@ -327,9 +331,9 @@
data
=
$form
.
data
(
'yiiActiveForm'
);
if
(
data
.
validated
)
{
var
event
=
$
.
Event
(
events
.
beforeSubmit
,
{
'isValid'
:
true
}
);
var
event
=
$
.
Event
(
events
.
beforeSubmit
);
$form
.
trigger
(
event
,
[
$form
]);
if
(
!
event
.
isValid
)
{
if
(
event
.
result
===
false
)
{
data
.
validated
=
false
;
data
.
submitting
=
false
;
return
false
;
...
...
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