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

moodleform_mod overwrites errors from moodleform

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • Hide
      1. Open lib/formslib.php in your preferred editor
      2. Find the validation($data, $files) function
      3. Change the content of the function:

        // From:
        return array();
        // To:
        return [
            'name' => 'Paumanhin',
        ];
        

      4. Log in to Moodle as a teacher, or administrator
      5. Open a course and turn editing mode on
      6. Create a new assignment
      7. Enter a name
      8. Press the "Save and display" button
        1. Confirm that an error was shown under the name with the error "Paumanhin"
      Show
      Open lib/formslib.php in your preferred editor Find the validation($data, $files) function Change the content of the function: // From: return array(); // To: return [ 'name' => 'Paumanhin', ]; Log in to Moodle as a teacher, or administrator Open a course and turn editing mode on Create a new assignment Enter a name Press the "Save and display" button Confirm that an error was shown under the name with the error "Paumanhin"

      In moodleform_mod::validation(), the parent::validation() call is made to allow the parent class (moodleform) to perform validation steps that may need to happen globally. However, two instructions later in the function, the errors array that was returned is immediately overwritten with an empty array.

      This has been a problem since Moodle 2.0, but it doesn't cause any problems at this moment. However, fixing the issue now avoids future surprises.

        1. MDL-75836_master.png
          MDL-75836_master.png
          22 kB
        2. MDL-75836_v311.png
          MDL-75836_v311.png
          23 kB
        3. MDL-75836_v400.png
          MDL-75836_v400.png
          22 kB

            jrchamp Jonathan Champ
            jrchamp Jonathan Champ
            Paul Holden Paul Holden
            Andrew Lyons Andrew Lyons
            John Edward Pedregosa John Edward Pedregosa
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 11 minutes
                2h 11m

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