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

Frozen forms cause javascript error: currentform is null

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • Hide

      With JS console open, try on as many browsers as possible.
      Remember that Opera does not support this functionality (unless they've changed their minds on that one)

      Test that the form checker still works:

      • Open a form in moodle (e.g. course editing)
        • Confirm no errors were shown in the JS console
      • Make some changes to the form
      • Refresh the page
        • Confirm that an error message was shown

      Test that it doesn't die a horrible death when it's unable to find a proper form:

      • Copy attached file 'formfreezetest.php' into $CFG->dirroot
      • Open the page containing the form
        • Confirm that no errors were shown in the JS console
      • Find the formchangechecker.js file in your Sources tab
      • Add a breakpoint around the new if (!currentform) line
      • Refresh the page to invoke the breakpoint
        • Step into the test to confirm that the return line is hit
      Show
      With JS console open, try on as many browsers as possible. Remember that Opera does not support this functionality (unless they've changed their minds on that one) Test that the form checker still works: Open a form in moodle (e.g. course editing) Confirm no errors were shown in the JS console Make some changes to the form Refresh the page Confirm that an error message was shown Test that it doesn't die a horrible death when it's unable to find a proper form: Copy attached file 'formfreezetest.php' into $CFG->dirroot Open the page containing the form Confirm that no errors were shown in the JS console Find the formchangechecker.js file in your Sources tab Add a breakpoint around the new if (!currentform) line Refresh the page to invoke the breakpoint Step into the test to confirm that the return line is hit

      Frozen forms cause javascript error: currentform is null

      • this is due to fact that no form tag is present for frozen forms, but code in /lib/yui/formchangechecker/formchangechecker.js::init() assumes form present.
        Suggested code fix:

        --- a/lib/yui/formchangechecker/formchangechecker.js
        +++ b/lib/yui/formchangechecker/formchangechecker.js
        @@ -23,6 +23,11 @@ YUI.add('moodle-core-formchangechecker',
         
                             // Add change events to the form elements
                             var currentform = Y.one(formid);
        +                    if (!currentform) {
        +                        return;
        +                    }
                             currentform.delegate('change', M.core_formchangechecker.set_form_changed, 'input', this);
                             currentform.delegate('change', M.core_formchangechecker.set_form_changed, 'textarea', this);
                             currentform.delegate('change', M.core_formchangechecker.set_form_changed, 'select', this);
        

            dobedobedoh Andrew Lyons
            brentboghosian Brent Boghosian
            Andrew Lyons Andrew Lyons
            Aparup Banerjee Aparup Banerjee
            Aparup Banerjee Aparup Banerjee
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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