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
51c02312
Commit
51c02312
authored
Jan 22, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1958 from 6pblcb/yiiActiveForm-beforeSubmit
Transfer beforeSubmit function after global validation all fields forms
parents
942370f8
d30ca6d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
31 deletions
+34
-31
yii.activeForm.js
framework/assets/yii.activeForm.js
+34
-31
No files found.
framework/assets/yii.activeForm.js
View file @
51c02312
...
...
@@ -127,6 +127,13 @@
var
$form
=
$
(
this
),
data
=
$form
.
data
(
'yiiActiveForm'
);
if
(
data
.
validated
)
{
if
(
data
.
settings
.
beforeSubmit
!==
undefined
)
{
if
(
data
.
settings
.
beforeSubmit
(
$form
)
==
false
)
{
data
.
validated
=
false
;
data
.
submitting
=
false
;
return
false
;
}
}
// continue submitting the form since validation passes
return
true
;
}
...
...
@@ -135,40 +142,36 @@
clearTimeout
(
data
.
settings
.
timer
);
}
data
.
submitting
=
true
;
if
(
!
data
.
settings
.
beforeSubmit
||
data
.
settings
.
beforeSubmit
(
$form
))
{
validate
(
$form
,
function
(
messages
)
{
var
errors
=
[];
$
.
each
(
data
.
attributes
,
function
()
{
if
(
updateInput
(
$form
,
this
,
messages
))
{
errors
.
push
(
this
.
input
);
}
});
updateSummary
(
$form
,
messages
);
if
(
errors
.
length
)
{
var
top
=
$form
.
find
(
errors
.
join
(
','
)).
first
().
offset
().
top
;
var
wtop
=
$
(
window
).
scrollTop
();
if
(
top
<
wtop
||
top
>
wtop
+
$
(
window
).
height
)
{
$
(
window
).
scrollTop
(
top
);
}
}
else
{
data
.
validated
=
true
;
var
$button
=
data
.
submitObject
||
$form
.
find
(
':submit:first'
);
// TODO: if the submission is caused by "change" event, it will not work
if
(
$button
.
length
)
{
$button
.
click
();
}
else
{
// no submit button in the form
$form
.
submit
();
}
return
;
validate
(
$form
,
function
(
messages
)
{
var
errors
=
[];
$
.
each
(
data
.
attributes
,
function
()
{
if
(
updateInput
(
$form
,
this
,
messages
))
{
errors
.
push
(
this
.
input
);
}
data
.
submitting
=
false
;
},
function
()
{
data
.
submitting
=
false
;
});
}
else
{
updateSummary
(
$form
,
messages
);
if
(
errors
.
length
)
{
var
top
=
$form
.
find
(
errors
.
join
(
','
)).
first
().
offset
().
top
;
var
wtop
=
$
(
window
).
scrollTop
();
if
(
top
<
wtop
||
top
>
wtop
+
$
(
window
).
height
)
{
$
(
window
).
scrollTop
(
top
);
}
}
else
{
data
.
validated
=
true
;
var
$button
=
data
.
submitObject
||
$form
.
find
(
':submit:first'
);
// TODO: if the submission is caused by "change" event, it will not work
if
(
$button
.
length
)
{
$button
.
click
();
}
else
{
// no submit button in the form
$form
.
submit
();
}
return
;
}
data
.
submitting
=
false
;
}
},
function
()
{
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