mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-38555-master' of https://github.com/lucisgit/moodle
This commit is contained in:
commit
44df0d9aaa
9
lib/form/submit.js
Normal file
9
lib/form/submit.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
M.form_submit = {};
|
||||||
|
|
||||||
|
M.form_submit.init = function(Y, options) {
|
||||||
|
Y.on('submit', function(e) {
|
||||||
|
if (!containsErrors) {
|
||||||
|
e.target.one('#'+options.submitid).setAttribute('disabled', 'true');
|
||||||
|
}
|
||||||
|
}, '#'+options.formid);
|
||||||
|
};
|
@ -38,6 +38,9 @@ require_once("HTML/QuickForm/submit.php");
|
|||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
class MoodleQuickForm_submit extends HTML_QuickForm_submit {
|
class MoodleQuickForm_submit extends HTML_QuickForm_submit {
|
||||||
|
/** @var string Need to store id of form for submission control in JS*/
|
||||||
|
var $_formid = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
@ -60,6 +63,7 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit {
|
|||||||
{
|
{
|
||||||
switch ($event) {
|
switch ($event) {
|
||||||
case 'createElement':
|
case 'createElement':
|
||||||
|
$this->_formid = $caller->getAttribute('id');
|
||||||
parent::onQuickFormEvent($event, $arg, $caller);
|
parent::onQuickFormEvent($event, $arg, $caller);
|
||||||
if ($caller->isNoSubmitButton($arg[0])){
|
if ($caller->isNoSubmitButton($arg[0])){
|
||||||
//need this to bypass client validation
|
//need this to bypass client validation
|
||||||
@ -98,4 +102,20 @@ class MoodleQuickForm_submit extends HTML_QuickForm_submit {
|
|||||||
$this->_flagFrozen = true;
|
$this->_flagFrozen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns HTML for this form element.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function toHtml(){
|
||||||
|
global $PAGE;
|
||||||
|
$options = array(
|
||||||
|
'submitid' => $this->getAttribute('id'),
|
||||||
|
'formid' => $this->_formid,
|
||||||
|
);
|
||||||
|
$str = parent::toHtml();
|
||||||
|
$module = array('name'=>'form_submit', 'fullpath'=>'/lib/form/submit.js');
|
||||||
|
$PAGE->requires->js_init_call('M.form_submit.init', array($options), true, $module);
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2096,6 +2096,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
|
|||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
|
|
||||||
var skipClientValidation = false;
|
var skipClientValidation = false;
|
||||||
|
var containsErrors = false;
|
||||||
|
|
||||||
function qf_errorHandler(element, _qfMsg) {
|
function qf_errorHandler(element, _qfMsg) {
|
||||||
div = element.parentNode;
|
div = element.parentNode;
|
||||||
@ -2204,6 +2205,7 @@ function validate_' . $this->_formName . '(frm) {
|
|||||||
var frm = document.getElementById(\''. $this->_attributes['id'] .'\')
|
var frm = document.getElementById(\''. $this->_attributes['id'] .'\')
|
||||||
var first_focus = false;
|
var first_focus = false;
|
||||||
' . $validateJS . ';
|
' . $validateJS . ';
|
||||||
|
containsErrors = !ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
//]]>
|
//]]>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user