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

Client side Form validation does not work in forms with short forms disabled

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Disable the following modules by going to site administration > plugins > filters > manage filters:

      • Filter glossary
      • Filter mathjax

      Forms with shortforms disabled:

      1. Go to a page with shortforms disabled. (i.e. Change Password page by going to user menu > preferences > change password (under the user account section)).
      2. Leave a required item as blank.
      3. Try to submit the form.

      Expected Results:

      • The form should not submit and a validation error message will be displayed.
      • If in Debugging mode, the JavaScript console should not repeatedly display "Event fired: " logs.

      Forms with shortforms enabled:

      1. Go to a page with shortforms enabled. (i.e. Edit User Profile page by going to user menu > profile > edit profile (under user account section)).
      2. Leave a required item as blank.
      3. Try to submit the form.

      Expected Results:

      • The form should not submit and a validation error message will be displayed.
      • If in Debugging mode, the JavaScript console should not repeatedly display "Event fired: " logs.

      Additional Tests (Optional)

      • Try modifying a moodleform subclass by disabling shortforms (i.e. add $mform->setDisableShortforms(); just below the $mform variable declaration inside course_edit_form->definition() method) and verify that client validation still works.
      • Repeat test from MDL-49783
      Show
      Disable the following modules by going to site administration > plugins > filters > manage filters: Filter glossary Filter mathjax Forms with shortforms disabled: Go to a page with shortforms disabled. (i.e. Change Password page by going to user menu > preferences > change password (under the user account section)). Leave a required item as blank. Try to submit the form. Expected Results: The form should not submit and a validation error message will be displayed. If in Debugging mode, the JavaScript console should not repeatedly display "Event fired: " logs. Forms with shortforms enabled: Go to a page with shortforms enabled. (i.e. Edit User Profile page by going to user menu > profile > edit profile (under user account section)). Leave a required item as blank. Try to submit the form. Expected Results: The form should not submit and a validation error message will be displayed. If in Debugging mode, the JavaScript console should not repeatedly display "Event fired: " logs. Additional Tests (Optional) Try modifying a moodleform subclass by disabling shortforms (i.e. add $mform->setDisableShortforms(); just below the $mform variable declaration inside course_edit_form->definition() method) and verify that client validation still works. Repeat test from MDL-49783
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-50852-master
    • Sprint:
      Team ';drop tables Sprint 10
    • Issue size:
      Medium

      Description

      Client side Form validation does not work in forms with short forms disabled
      Create a form that has either no collapsible elements or has $mform->setDisableShortforms(true);
      Try use client side validation, it will cause 100's of errors in the console and submit anyway

      Cause: When short forms are disabled, or there are no collapisble elements and therefore shortforms are not required the shortform.js is not included. The shortform.js has the function that handles the event , for some reason when registering the event when the function doesnt exist causes yui to go nuts.
      Solution: Dont register the global event handlers, when the events are fired when shortform.js is included it registers itself as a watcher

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Sep/15