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

moodleform_mod addRule client regex type small bug (quotes lost)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a bug
    • Minor
    • None
    • 2.3.3
    • Forms Library
    • None
    • MOODLE_23_STABLE

    Description

      I am a very new Moodle fan so apologies if this is not a bug but a misuse (I haven´t read all docs yet ).
      The issue is that when I add a rule to a field in a subclass of moodleform_mod I use the syntax:

      $mform->addRule('myfield', get_string('myErrorMessageId','myMod'), 'regex', "myRegexpression", 'client');

      but the generated javascript code is, supposed myRegExpression is "[0-9]

      {0,5}":

      var regex = [0-9]{0,5}

      ;

      but, if I am not wrong, it should be:

      var regex = '[0-9]{0,5}';

      If you take a look at file moodleroot/lib/pear/HTML/QuickForm/Rule/Regex.php , you'll find the following sentence in line 84 (moodle 2.3):

      return array(" var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");

      I guess if it should rather be:

      return array(" var regex = '" . $regex . "' ;\n", "{jsVar} != '' && !regex.test({jsVar})");

      Notice the opening and closing quote surrounding the value of $regex.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jlsimon J. Luis Simón
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.