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
51863437
Commit
51863437
authored
Jul 28, 2014
by
Alex-Code
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deferred validation
Added support of deferred to ```ActiveForm``` validation.
parent
1e9350ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
50 deletions
+52
-50
yii.activeForm.js
framework/assets/yii.activeForm.js
+52
-50
No files found.
framework/assets/yii.activeForm.js
View file @
51863437
...
@@ -280,70 +280,72 @@
...
@@ -280,70 +280,72 @@
var
validate
=
function
(
$form
,
successCallback
,
errorCallback
)
{
var
validate
=
function
(
$form
,
successCallback
,
errorCallback
)
{
var
data
=
$form
.
data
(
'yiiActiveForm'
),
var
data
=
$form
.
data
(
'yiiActiveForm'
),
needAjaxValidation
=
false
,
needAjaxValidation
=
false
,
messages
=
{};
messages
=
{},
deferreds
=
[];
$
.
each
(
data
.
attributes
,
function
()
{
$
.
each
(
data
.
attributes
,
function
()
{
if
(
data
.
submitting
||
this
.
status
===
2
||
this
.
status
===
3
)
{
if
(
data
.
submitting
||
this
.
status
===
2
||
this
.
status
===
3
)
{
var
msg
=
[];
var
msg
=
[];
messages
[
this
.
id
]
=
msg
;
if
(
!
data
.
settings
.
beforeValidate
||
data
.
settings
.
beforeValidate
(
$form
,
this
,
msg
))
{
if
(
!
data
.
settings
.
beforeValidate
||
data
.
settings
.
beforeValidate
(
$form
,
this
,
msg
))
{
if
(
this
.
validate
)
{
if
(
this
.
validate
)
{
this
.
validate
(
this
,
getValue
(
$form
,
this
),
msg
);
this
.
validate
(
this
,
getValue
(
$form
,
this
),
msg
,
deferreds
);
}
}
if
(
msg
.
length
)
{
if
(
this
.
enableAjaxValidation
)
{
messages
[
this
.
id
]
=
msg
;
}
else
if
(
this
.
enableAjaxValidation
)
{
needAjaxValidation
=
true
;
needAjaxValidation
=
true
;
}
}
}
}
}
}
});
});
if
(
needAjaxValidation
&&
(
!
data
.
submitting
||
$
.
isEmptyObject
(
messages
)))
{
$
.
when
.
apply
(
this
,
deferreds
).
always
(
function
()
{
// Perform ajax validation when at least one input needs it.
if
(
needAjaxValidation
&&
(
!
data
.
submitting
||
$
.
isEmptyObject
(
messages
)))
{
// If the validation is triggered by form submission, ajax validation
// Perform ajax validation when at least one input needs it.
// should be done only when all inputs pass client validation
// If the validation is triggered by form submission, ajax validation
var
$button
=
data
.
submitObject
,
// should be done only when all inputs pass client validation
extData
=
'&'
+
data
.
settings
.
ajaxParam
+
'='
+
$form
.
prop
(
'id'
);
var
$button
=
data
.
submitObject
,
if
(
$button
&&
$button
.
length
&&
$button
.
prop
(
'name'
))
{
extData
=
'&'
+
data
.
settings
.
ajaxParam
+
'='
+
$form
.
prop
(
'id'
);
extData
+=
'&'
+
$button
.
prop
(
'name'
)
+
'='
+
$button
.
prop
(
'value'
);
if
(
$button
&&
$button
.
length
&&
$button
.
prop
(
'name'
))
{
}
extData
+=
'&'
+
$button
.
prop
(
'name'
)
+
'='
+
$button
.
prop
(
'value'
);
$
.
ajax
({
}
url
:
data
.
settings
.
validationUrl
,
$
.
ajax
({
type
:
$form
.
prop
(
'method'
),
url
:
data
.
settings
.
validationUrl
,
data
:
$form
.
serialize
()
+
extData
,
type
:
$form
.
prop
(
'method'
),
dataType
:
data
.
settings
.
ajaxDataType
,
data
:
$form
.
serialize
()
+
extData
,
complete
:
function
(
jqXHR
,
textStatus
)
{
dataType
:
data
.
settings
.
ajaxDataType
,
if
(
data
.
settings
.
ajaxComplete
)
{
complete
:
function
(
jqXHR
,
textStatus
)
{
data
.
settings
.
ajaxComplete
(
$form
,
jqXHR
,
textStatus
);
if
(
data
.
settings
.
ajaxComplete
)
{
}
data
.
settings
.
ajaxComplete
(
$form
,
jqXHR
,
textStatus
);
},
}
beforeSend
:
function
(
jqXHR
,
textStatus
)
{
},
if
(
data
.
settings
.
ajaxBeforeSend
)
{
beforeSend
:
function
(
jqXHR
,
textStatus
)
{
data
.
settings
.
ajaxBeforeSend
(
$form
,
jqXHR
,
textStatus
);
if
(
data
.
settings
.
ajaxBeforeSend
)
{
}
data
.
settings
.
ajaxBeforeSend
(
$form
,
jqXHR
,
textStatus
);
},
}
success
:
function
(
msgs
)
{
},
if
(
msgs
!==
null
&&
typeof
msgs
===
'object'
)
{
success
:
function
(
msgs
)
{
$
.
each
(
data
.
attributes
,
function
()
{
if
(
msgs
!==
null
&&
typeof
msgs
===
'object'
)
{
if
(
!
this
.
enableAjaxValidation
)
{
$
.
each
(
data
.
attributes
,
function
()
{
delete
msgs
[
this
.
id
];
if
(
!
this
.
enableAjaxValidation
)
{
}
delete
msgs
[
this
.
id
];
});
}
successCallback
(
$
.
extend
({},
messages
,
msgs
));
});
}
else
{
successCallback
(
$
.
extend
({},
messages
,
msgs
));
successCallback
(
messages
);
}
else
{
}
successCallback
(
messages
);
},
}
error
:
errorCallback
},
});
error
:
errorCallback
}
else
if
(
data
.
submitting
)
{
});
// delay callback so that the form can be submitted without problem
}
else
if
(
data
.
submitting
)
{
setTimeout
(
function
()
{
// delay callback so that the form can be submitted without problem
setTimeout
(
function
()
{
successCallback
(
messages
);
},
200
);
}
else
{
successCallback
(
messages
);
successCallback
(
messages
);
},
200
);
}
}
else
{
});
successCallback
(
messages
);
}
};
};
/**
/**
...
...
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