From 0befbdfd8f0d5f6a25b71e49a363c8c608fc371a Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Tue, 5 Dec 2006 13:21:40 +0000 Subject: [PATCH] petr's patch to fix problem with htmlarea breaking clientside validation. Also using id's with same naming convention as formslib for htmlareas. --- lib/editor/htmlarea/htmlarea.php | 4 +++- lib/formslib.php | 4 ++++ lib/weblib.php | 4 ++-- message/send.php | 2 +- mod/lesson/action/editpage.php | 14 +++++++------- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/editor/htmlarea/htmlarea.php b/lib/editor/htmlarea/htmlarea.php index 2082771406..c6a2908012 100644 --- a/lib/editor/htmlarea/htmlarea.php +++ b/lib/editor/htmlarea/htmlarea.php @@ -634,12 +634,14 @@ HTMLArea.prototype.generate = function () { } // Moodle hack end. var a = this.__msh_prevOnSubmit; + var ret = true; // call previous submit methods if they were there. if (typeof a != "undefined") { for (var i = a.length; --i >= 0;) { - a[i](); + ret = a[i]() && ret; } } + return ret; }; if (typeof f.onreset == "function") { var funcref = f.onreset; diff --git a/lib/formslib.php b/lib/formslib.php index 57a7a5cf33..0bdbcc0117 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -810,12 +810,16 @@ function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element) $element->updateAttributes(array('onBlur' => $onBlur . $valFunc, 'onChange' => $onChange . $valFunc)); } +// do not rely on frm function parameter, because htmlarea breaks it when overloading the onsubmit method $js .= ' function validate_' . $this->_attributes['id'] . '(frm) { if (skipClientValidation) { return true; } var ret = true; + + var frm = document.getElementById(\''. $this->_attributes['id'] .'\') + ' . $validateJS . '; return ret; } diff --git a/lib/weblib.php b/lib/weblib.php index 8f755acb5e..e14fcb7e97 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3578,7 +3578,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v } } } - $str .= '