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
d30ca6d1
Commit
d30ca6d1
authored
Jan 14, 2014
by
aleksandr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beforeSubmit function after global validation all fields forms
parent
ec0e348a
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 @
d30ca6d1
...
@@ -127,6 +127,13 @@
...
@@ -127,6 +127,13 @@
var
$form
=
$
(
this
),
var
$form
=
$
(
this
),
data
=
$form
.
data
(
'yiiActiveForm'
);
data
=
$form
.
data
(
'yiiActiveForm'
);
if
(
data
.
validated
)
{
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
// continue submitting the form since validation passes
return
true
;
return
true
;
}
}
...
@@ -135,40 +142,36 @@
...
@@ -135,40 +142,36 @@
clearTimeout
(
data
.
settings
.
timer
);
clearTimeout
(
data
.
settings
.
timer
);
}
}
data
.
submitting
=
true
;
data
.
submitting
=
true
;
if
(
!
data
.
settings
.
beforeSubmit
||
data
.
settings
.
beforeSubmit
(
$form
))
{
validate
(
$form
,
function
(
messages
)
{
validate
(
$form
,
function
(
messages
)
{
var
errors
=
[];
var
errors
=
[];
$
.
each
(
data
.
attributes
,
function
()
{
$
.
each
(
data
.
attributes
,
function
()
{
if
(
updateInput
(
$form
,
this
,
messages
))
{
if
(
updateInput
(
$form
,
this
,
messages
))
{
errors
.
push
(
this
.
input
);
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
;
}
}
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
;
data
.
submitting
=
false
;
}
},
function
()
{
data
.
submitting
=
false
;
});
return
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