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

Form-change-checker: a way to have a submit button in the form which does not save the date

XMLWordPrintable

    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_39_STABLE
    • Hide
      1. Save the attached test.php in the root of your moodle site.
      2. Visit the URL .../test.php.
      3. Type something in the 'Important' input.
      4. Try to navigate away (e.g. by clicking the site name in the top left).
      5. Verify that you get the "data you have entered may not be saved" warning.
      6. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state.
      7. Type something in the 'Not important' input.
      8. Try to navigate away (e.g. by clicking the site name in the top left).
      9. Verify that you do not an unsaved data warning.
      10. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state.
      11. Type something in the 'Important' input.
      12. Click the Submit button.
      13. Verify that you do not an unsaved data warning.
      14. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state.
      15. Type something in the 'Important' input.
      16. Click the Cancel button.
      17. Verify that you get the "data you have entered may not be saved" warning.
      Show
      Save the attached test.php in the root of your moodle site. Visit the URL .../test.php. Type something in the 'Important' input. Try to navigate away (e.g. by clicking the site name in the top left). Verify that you get the "data you have entered may not be saved" warning. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state. Type something in the 'Not important' input. Try to navigate away (e.g. by clicking the site name in the top left). Verify that you do not an unsaved data warning. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state. Type something in the 'Important' input. Click the Submit button. Verify that you do not an unsaved data warning. Force refresh the page, ignoring any unsaved data warnings, to clear the unsaved data state. Type something in the 'Important' input. Click the Cancel button. Verify that you get the "data you have entered may not be saved" warning.

      I need this for https://moodle.org/plugins/filter_embedquestion.

      My form has a button which does not acutally save the data. (It is a sort-of reset button.) I want it to give the standard warning if you change some ther data and then click the button.

      This is not currently possible becuase any submit button always marks the form data as saved: https://github.com/moodle/moodle/blob/cb38ab1e3926720b3230ce20b66a9c46c398eb80/lib/yui/src/formchangechecker/js/formchangechecker.js#L56.

      I want to introduce a mechanism like 'ignoredirty' method (which does the opposite and gets it to ignore changes in certain form fields.

      I think this sort of thing is better done with data attributes than CSS classes. Therefore, I am proposing to add an attribute data-formchangechecker-ignore-submit.

      At the same time, I will add data-formchangechecker-ignore-dirty as an alternative to the existing CSS class (but I won't remove the existing class because backwards compatibility).

        1. MDL-67857.jpg
          MDL-67857.jpg
          46 kB
        2. test.php
          2 kB

            timhunt Tim Hunt
            timhunt Tim Hunt
            Mark Johnson Mark Johnson
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            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 - 6 hours, 4 minutes
                6h 4m

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