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

AJAX exceptions thrown when submitting modal/dynamic forms never caught

XMLWordPrintable

    • MOODLE_311_STABLE
    • MOODLE_311_STABLE
    • Hide

      Apply patch

      1. Make the following change in admin/tool/dataprivacy/classes/form/contactdpo.php to simulate a genuine exception thrown on form submission:

      --- a/admin/tool/dataprivacy/classes/form/contactdpo.php
      +++ b/admin/tool/dataprivacy/classes/form/contactdpo.php
      @@ -77,6 +77,7 @@ class contactdpo extends dynamic_form {
            * @return array
            */
           public function process_dynamic_submission() {
      +        throw new \coding_exception('Oh no...');
               return external::contact_dpo($this->get_data()->message);
           }
       

      Test

      1. Log in as admin
      2. Navigate to Users > Privacy and policies > Privacy settings in site administration
      3. Enable Contact the privacy officer and save changes
      4. Navigate to your profile page
      5. Press Privacy and policies > Contact the privacy policy
      6. Enter some text in the Message field and press Send
      7. Confirm you see Coding error detected... exception dialogue
      Show
      Apply patch Make the following change in admin/tool/dataprivacy/classes/form/contactdpo.php to simulate a genuine exception thrown on form submission: --- a/admin/tool/dataprivacy/classes/form/contactdpo.php +++ b/admin/tool/dataprivacy/classes/form/contactdpo.php @@ -77,6 +77,7 @@ class contactdpo extends dynamic_form { * @return array */ public function process_dynamic_submission() { + throw new \coding_exception('Oh no...'); return external::contact_dpo($this->get_data()->message); } Test Log in as admin Navigate to Users > Privacy and policies > Privacy settings in site administration Enable Contact the privacy officer and save changes Navigate to your profile page Press Privacy and policies > Contact the privacy policy Enter some text in the Message field and press Send Confirm you see Coding error detected... exception dialogue

      Found this while working on some modal forms for Report builder, and having to use browser network tools to see actual exception when submitting modal forms

      Appears the code intends to handle AJAX exceptions, but it doesn't work. Currently if an exception is thrown, then the modal form remains on screen and no indication is given to the user that something went wrong

            pholden Paul Holden
            pholden Paul Holden
            Mikel Martín Corrales Mikel Martín Corrales
            Andrew Lyons Andrew Lyons
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 40 minutes
                1h 40m

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