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

Forms lib throws fatal error if you add required rule to already required field

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.5.2
    • Forms Library
    • MOODLE_25_STABLE

      If you something like:

      $mform->addElement('editor', 'questiontext', get_string('questiontext', 'question'),
                       array('rows' => 15), $this->editoroptions);
      $mform->setType('questiontext', PARAM_RAW);
      $mform->addRule('questiontext', null, 'required', null, 'client');
      $mform->addRule('questiontext', null, 'required', null, 'client');
      

      You get a fatal (and non-sensical) error. While the above example is kinda ridiculous, it was found because a plugin wants to mark standard field as required, and we were changing the standard field to be required.

      This should do one of these:

      1. Be silent. (Probably just ignore the second rule)
      2. Throw a dev warning.
      3. Throw a sensical fatal message.

      I probably vote for number 2.

            Unassigned Unassigned
            emerrill Eric Merrill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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