mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'MDL-40132_31' of https://github.com/IvannavISer/moodle
This commit is contained in:
commit
fc893bc42d
@ -2165,12 +2165,14 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
|
||||
}
|
||||
//for editor element, [text] is appended to the name.
|
||||
$fullelementname = $elementName;
|
||||
if ($element->getType() == 'editor') {
|
||||
$fullelementname .= '[text]';
|
||||
//Add format to rule as moodleform check which format is supported by browser
|
||||
//it is not set anywhere... So small hack to make sure we pass it down to quickform
|
||||
if (is_null($rule['format'])) {
|
||||
$rule['format'] = $element->getFormat();
|
||||
if (is_object($element) && $element->getType() == 'editor') {
|
||||
if ($element->getType() == 'editor') {
|
||||
$fullelementname .= '[text]';
|
||||
// Add format to rule as moodleform check which format is supported by browser
|
||||
// it is not set anywhere... So small hack to make sure we pass it down to quickform.
|
||||
if (is_null($rule['format'])) {
|
||||
$rule['format'] = $element->getFormat();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix for bug displaying errors for elements in a group
|
||||
@ -2263,7 +2265,12 @@ require(["core/event", "jquery"], function(Event, $) {
|
||||
$elementName);
|
||||
$valFunc = 'validate_' . $this->_formName . '_' . $escapedElementName . '(ev.target, \''.$escapedElementName.'\')';
|
||||
|
||||
$js .= '
|
||||
if (!is_array($element)) {
|
||||
$element = [$element];
|
||||
}
|
||||
foreach ($element as $elem) {
|
||||
if (key_exists('id', $elem->_attributes)) {
|
||||
$js .= '
|
||||
function validate_' . $this->_formName . '_' . $escapedElementName . '(element, escapedName) {
|
||||
if (undefined == element) {
|
||||
//required element was not found, then let form be submitted without client side validation
|
||||
@ -2286,13 +2293,15 @@ require(["core/event", "jquery"], function(Event, $) {
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById(\'' . $element->_attributes['id'] . '\').addEventListener(\'blur\', function(ev) {
|
||||
document.getElementById(\'' . $elem->_attributes['id'] . '\').addEventListener(\'blur\', function(ev) {
|
||||
' . $valFunc . '
|
||||
});
|
||||
document.getElementById(\'' . $element->_attributes['id'] . '\').addEventListener(\'change\', function(ev) {
|
||||
document.getElementById(\'' . $elem->_attributes['id'] . '\').addEventListener(\'change\', function(ev) {
|
||||
' . $valFunc . '
|
||||
});
|
||||
';
|
||||
}
|
||||
}
|
||||
$validateJS .= '
|
||||
ret = validate_' . $this->_formName . '_' . $escapedElementName.'(frm.elements[\''.$elementName.'\'], \''.$escapedElementName.'\') && ret;
|
||||
if (!ret && !first_focus) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user