Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-35402

Error when using two separate rules for editor element

    Details

      Description

      Code causing the error:

      $mform->addElement(
      	           'editor',
      	            $fieldname,
      	            "$this->label",
      	            array('class' => 'form_input', 'canUseHtmlEditor'=>'detect', 'rows'=> '20', 'cols'=>'65')
      	    );
       
       
              if (!empty($this->minimumlength)) $mform->addRule($fieldname, null, 'minlength', $this->minimumlength, 'client');
              if (!empty($this->maximumlength)) $mform->addRule($fieldname, null, 'maxlength', $this->maximumlength, 'client');
              if (!empty($this->required)) $mform->addRule($fieldname, null, 'required', null, 'client');

      Error:

      Fatal error: Call to undefined method HTML_QuickForm_Error::isFrozen() in /var/www/wd2tst/docroot/blind/lib/formslib.php on line 1789

      Problem:
      When adding rules, they are held in the _rules property of MoodleQuickForm, then looped over by code in getValidationScript(), which adds "['text']" to the end if it's an editor plugin at line 1800:

      if ($element->getType() == 'editor') {
                              $elementName .= '[text]';

      So when the next iteration of the loop happens, the bit that gets the element at line 1786 doesn't work:

                              $element =& $this->getElement($elementName);
       

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    11/Nov/13