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
88191bbe
Commit
88191bbe
authored
Jul 24, 2014
by
Thiago Talma
Committed by
Carsten Brandt
Jul 25, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New callback functions for form validation using Ajax.
close #4436
parent
42eba969
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
yii.activeForm.js
framework/assets/yii.activeForm.js
+16
-0
ActiveForm.php
framework/widgets/ActiveForm.php
+21
-1
No files found.
framework/CHANGELOG.md
View file @
88191bbe
...
...
@@ -152,6 +152,7 @@ Yii Framework 2 Change Log
-
Enh #4297: Added check for DOM extension to requirements (samdark)
-
Enh #4317: Added
`absoluteAuthTimeout`
to yii
\w
eb
\U
ser (ivokund, nkovacs)
-
Enh #4360: Added client validation support for file validator (Skysplit)
-
Enh #4436: Added callback functions to AJAX-based form validation (thiagotalma)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
framework/assets/yii.activeForm.js
View file @
88191bbe
...
...
@@ -44,6 +44,12 @@
// a callback that is called after an attribute is validated. The signature of the callback should be:
// function ($form, attribute, messages)
afterValidate
:
undefined
,
// a pre-request callback function on AJAX-based validation. The signature of the callback should be:
// function ($form, jqXHR, textStatus)
ajaxBeforeSend
:
undefined
,
// a function to be called when the request finishes on AJAX-based validation. The signature of the callback should be:
// function ($form, jqXHR, textStatus)
ajaxComplete
:
undefined
,
// the GET parameter name indicating an AJAX-based validation
ajaxParam
:
'ajax'
,
// the type of data that you're expecting back from the server
...
...
@@ -306,6 +312,16 @@
type
:
$form
.
prop
(
'method'
),
data
:
$form
.
serialize
()
+
extData
,
dataType
:
data
.
settings
.
ajaxDataType
,
complete
:
function
(
jqXHR
,
textStatus
)
{
if
(
data
.
settings
.
ajaxComplete
)
{
data
.
settings
.
ajaxComplete
(
$form
,
jqXHR
,
textStatus
);
}
},
beforeSend
:
function
(
jqXHR
,
textStatus
)
{
if
(
data
.
settings
.
ajaxBeforeSend
)
{
data
.
settings
.
ajaxBeforeSend
(
$form
,
jqXHR
,
textStatus
);
}
},
success
:
function
(
msgs
)
{
if
(
msgs
!==
null
&&
typeof
msgs
===
'object'
)
{
$
.
each
(
data
.
attributes
,
function
()
{
...
...
framework/widgets/ActiveForm.php
View file @
88191bbe
...
...
@@ -152,6 +152,26 @@ class ActiveForm extends Widget
*/
public
$afterValidate
;
/**
* @var string|JsExpression a JS pre-request callback function on AJAX-based validation.
* The signature of the callback should be:
*
* ~~~
* function ($form, jqXHR, textStatus) {
* }
* ~~~
*/
public
$ajaxBeforeSend
;
/**
* @var string|JsExpression a JS callback to be called when the request finishes on AJAX-based validation.
* The signature of the callback should be:
*
* ~~~
* function ($form, jqXHR, textStatus) {
* }
* ~~~
*/
public
$ajaxComplete
;
/**
* @var array the client validation options for individual attributes. Each element of the array
* represents the validation options for a particular attribute.
* @internal
...
...
@@ -208,7 +228,7 @@ class ActiveForm extends Widget
if
(
$this
->
validationUrl
!==
null
)
{
$options
[
'validationUrl'
]
=
Url
::
to
(
$this
->
validationUrl
);
}
foreach
([
'beforeSubmit'
,
'beforeValidate'
,
'afterValidate'
]
as
$name
)
{
foreach
([
'beforeSubmit'
,
'beforeValidate'
,
'afterValidate'
,
'ajaxBeforeSend'
,
'ajaxComplete'
]
as
$name
)
{
if
((
$value
=
$this
->
$name
)
!==
null
)
{
$options
[
$name
]
=
$value
instanceof
JsExpression
?
$value
:
new
JsExpression
(
$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