Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-28987: Affix [text] to editor element in JS validation and add bl…

…ur event
  • Loading branch information...
commit 567282021a475d8a1677895a7e40670d247e07d9 1 parent 9805fb9
@aolley aolley authored Rajesh Taneja committed
Showing with 16 additions and 1 deletion.
  1. +6 −1 lib/form/editor.php
  2. +10 −0 lib/formslib.php
View
7 lib/form/editor.php
@@ -204,7 +204,12 @@ function toHtml() {
$rows = empty($this->_attributes['rows']) ? 15 : $this->_attributes['rows'];
$cols = empty($this->_attributes['cols']) ? 80 : $this->_attributes['cols'];
- $str .= '<div><textarea id="'.$id.'" name="'.$elname.'[text]" rows="'.$rows.'" cols="'.$cols.'">';
+ //Apply editor rules is required
+ $editorrules = '';
+ if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
+ $editorrules = 'onblur="'.$this->getAttribute('onblur').'" onchange="'.$this->getAttribute('onchange').'"';
+ }
+ $str .= '<div><textarea id="'.$id.'" name="'.$elname.'[text]" rows="'.$rows.'" cols="'.$cols.'"'.$editorrules.'>';
$str .= s($text);
$str .= '</textarea></div>';
View
10 lib/formslib.php
@@ -1712,6 +1712,9 @@ function getValidationScript()
}
// Fix for bug displaying errors for elements in a group
//$test[$elementName][] = $registry->getValidationScript($element, $elementName, $rule);
+ if ($element->_type == 'editor') {
+ $elementName .= '[text]';
+ }
$test[$elementName][0][] = $registry->getValidationScript($element, $elementName, $rule);
$test[$elementName][1]=$element;
//end of fix
@@ -1784,6 +1787,13 @@ function qf_errorHandler(element, _qfMsg) {
'/[_\[\]]/',
create_function('$matches', 'return sprintf("_%2x",ord($matches[0]));'),
$elementName);
+ if ($element->_type == 'editor') {
+ $tinyjs = "
+ if (tinyMCE.get('id_{$element->getName()}')) {
+ tinyMCE.get('id_{$element->getName()}').save();
+ }";
+ array_unshift($jsArr, $tinyjs);
+ }
$js .= '
function validate_' . $this->_formName . '_' . $escapedElementName . '(element) {
if (undefined == element) {
Please sign in to comment.
Something went wrong with that request. Please try again.