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

Frozen forms cause javascript error: currentform is null

    XMLWordPrintable

    Details

    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull Master Branch:

      Description

      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);
        

        Attachments

          Activity

            People

            Assignee:
            dobedobedoh Andrew Nicols
            Reporter:
            brentboghosian Brent Boghosian
            Peer reviewer:
            Andrew Nicols
            Integrator:
            Aparup Banerjee
            Tester:
            Aparup Banerjee
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Mar/13