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

          Issue Links

            Activity

            Hide
            davosmith Davo Smith added a comment -

            This is a simple fix for the bug (which just hit me on a client's site).

            Show
            davosmith Davo Smith added a comment - This is a simple fix for the bug (which just hit me on a client's site).
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            Thanks for fixing this Davo,

            Patch looks spot on.. pushing for integration...
            [y] Syntax
            [y] Whitespace
            [y] Output
            [-] Language
            [-] Databases
            [y] Testing (instructions and automated tests)
            [-] Security
            [-] Documentation
            [y] Git
            [-] Third party code
            [y] Sanity check

            Show
            rajeshtaneja Rajesh Taneja added a comment - Thanks for fixing this Davo, Patch looks spot on.. pushing for integration... [y] Syntax [y] Whitespace [y] Output [-] Language [-] Databases [y] Testing (instructions and automated tests) [-] Security [-] Documentation [y] Git [-] Third party code [y] Sanity check
            Hide
            poltawski Dan Poltawski added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            poltawski Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            Hide
            marina Marina Glancy added a comment -

            Thanks Davo, integrated in 2.4, 2.5 and master. Good spotting!

            Show
            marina Marina Glancy added a comment - Thanks Davo, integrated in 2.4, 2.5 and master. Good spotting!
            Hide
            damyon Damyon Wiese added a comment -

            I stole this test.

            Passing - but I raised a new bug on 25 and master because the minlength/maxlength rules do not seem to work properly on 'editor' fields.

            MDL-42543

            Show
            damyon Damyon Wiese added a comment - I stole this test. Passing - but I raised a new bug on 25 and master because the minlength/maxlength rules do not seem to work properly on 'editor' fields. MDL-42543
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            "Aequam memento rebus in arduis servare mentem"

            Many thanks for your hard work, this is now part of "Moodle, the LMS". Closing!

            Ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - "Aequam memento rebus in arduis servare mentem" Many thanks for your hard work, this is now part of "Moodle, the LMS". Closing! Ciao

              People

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

                Dates

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