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

Details

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

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              emerrill Eric Merrill
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: