Moodle
  1. Moodle
  2. MDL-20988

Javascript validation errors if rules set for mforms editor

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Forms Library
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      2519

      Description

      When using the new mforms editor element in conjunction with rules most notably making the field required validation fails due to a JavaScript error.
      The problem is very easy to diagnose in that the generated validation routine is been called with the name of the element as set when creating the element. However the editor creates it primary element as name[text], thus the arg passed to the validation routine is undefined and as the JS there is particularly shotty the whole validation for the form falls over.

      To duplicate this:
      Using Firefox + the Firebug extension and JavaScript debugging enabled simply log into any course, turn on editing and attempt to create new module.
      The introeditor is a required field and when you attempt to submit Firebug will fire up and detect the JavaScript error as part of the validation for the editor.

      Solution: I couldn't think of any nice way to solve this one short of making ugly hacks in the functions that build the validation JS, or making major changes to either the mforms editor element of the way in which mforms generates JS as a whole.....

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          After I finish my current work on themes I am going to work on more general editor embedding, this is a known problem even in 1.9.x where locking and forcing of content in textarea does not work.

          Show
          Petr Škoda added a comment - After I finish my current work on themes I am going to work on more general editor embedding, this is a known problem even in 1.9.x where locking and forcing of content in textarea does not work.
          Hide
          Dongsheng Cai added a comment -

          have to modify pear/HTML/QuickForm/RuleRegistry.php to fix the validation error.

          Another one is from lib/formslib.php line 1656, editor element should use element[text] as element name.

          Show
          Dongsheng Cai added a comment - have to modify pear/HTML/QuickForm/RuleRegistry.php to fix the validation error. Another one is from lib/formslib.php line 1656, editor element should use element [text] as element name.
          Hide
          Jérôme Mouneyrac added a comment - - edited

          just coming for news about my original problem MDL-22451. When updating an advertised course, the creator notes field doesn't seem to care about the setDefault(). What is the status about editor and setDefault() rule ? Note that the addRule(required), originally also not working, has been fixed

          Show
          Jérôme Mouneyrac added a comment - - edited just coming for news about my original problem MDL-22451 . When updating an advertised course, the creator notes field doesn't seem to care about the setDefault(). What is the status about editor and setDefault() rule ? Note that the addRule(required), originally also not working, has been fixed
          Hide
          Jérôme Mouneyrac added a comment -

          just for people having the same issue, the way to setDefault() for 'editor' is:

          at the end of your form:

          $data = new stdClass();
          $data->editor_id = array();
          $data->editor_id['text'] = $thedefaulttext;
          $data->editor_id['format'] = $thedefaultformat;
          $this->set_data($data);

          Show
          Jérôme Mouneyrac added a comment - just for people having the same issue, the way to setDefault() for 'editor' is: at the end of your form: $data = new stdClass(); $data->editor_id = array(); $data->editor_id ['text'] = $thedefaulttext; $data->editor_id ['format'] = $thedefaultformat; $this->set_data($data);
          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d.

          TW9vZGxlDQo=

          Show
          Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d. TW9vZGxlDQo=
          Hide
          Michael de Raadt added a comment -

          I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          This is being done as part of a bulk annual clean-up of issues.

          If you still believe this is an issue in supported versions, please create a new issue.

          Show
          Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. This is being done as part of a bulk annual clean-up of issues. If you still believe this is an issue in supported versions, please create a new issue.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: