From 6c0f2235a4afcb6b596531c431f84429757d3cbd Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Wed, 24 Aug 2016 11:34:18 +0100 Subject: [PATCH] Disable client-side validation on all admin forms #2942 * Revert "Disable client-side validation on Django 1.10 for multipart forms" This reverts commit 197d85ce9f674e319cc7d7d0fa6e0a05dc6a46d7. * Disable client-side validation on all admin forms Client-side validation fails to handle all the nuances of how forms are used in Wagtail, such as indicating errors across tabbed forms, and generally results in a worse user experience than our existing server-side validation. Fixes #2934 * Don't pre-emptively validate long-running forms if novalidate is set We run checkValidity before enabling the spinner on long-running forms, so that we don't end up with a form that's been blocked from submission but still has the spinner running. Unfortunately, if novalidate is set, then checkValidity still returns False and aborts enabling the spinner, even though the 'real' validation (the one that prevents submission) never happens. To make matters worse, if we abort before we've set up the cancelSpinner function, and then promptly encounter a custom onsubmit handler that recognises the error and attempts to call cancelSpinner, the JS breaks completely. Eww. To remedy this, we now only run checkValidity on forms that don't have novalidate, and only after setting up cancelSpinner. --- .../templates/modeladmin/choose_parent.html | 2 +- .../modeladmin/templates/modeladmin/create.html | 4 ++-- .../settings/templates/wagtailsettings/edit.html | 6 +++--- .../templates/wagtailsearchpromotions/add.html | 2 +- .../templates/wagtailsearchpromotions/edit.html | 2 +- .../static_src/wagtailadmin/js/core.js | 14 +++++++------- .../wagtailadmin/account/change_password.html | 2 +- .../account/notification_preferences.html | 2 +- .../account/password_reset/confirm.html | 2 +- .../templates/wagtailadmin/chooser/email_link.html | 2 +- .../wagtailadmin/chooser/external_link.html | 2 +- .../templates/wagtailadmin/generic/create.html | 4 ++-- .../templates/wagtailadmin/generic/edit.html | 4 ++-- .../wagtailadmin/templates/wagtailadmin/login.html | 2 +- .../wagtailadmin/page_privacy/set_privacy.html | 2 +- .../templates/wagtailadmin/pages/copy.html | 2 +- .../templates/wagtailadmin/pages/create.html | 2 +- .../templates/wagtailadmin/pages/edit.html | 2 +- .../templates/wagtailadmin/shared/header.html | 2 +- .../wagtailadmin/templatetags/wagtailadmin_tags.py | 14 -------------- .../templates/wagtaildocs/chooser/chooser.html | 6 +++--- .../templates/wagtaildocs/documents/add.html | 4 ++-- .../templates/wagtaildocs/documents/edit.html | 4 ++-- .../templates/wagtaildocs/documents/index.html | 2 +- .../templates/wagtaildocs/multiple/add.html | 4 ++-- .../templates/wagtaildocs/multiple/edit_form.html | 4 ++-- .../templates/wagtailembeds/chooser/chooser.html | 2 +- .../templates/wagtailforms/index_submissions.html | 2 +- .../templates/wagtailimages/chooser/chooser.html | 6 +++--- .../wagtailimages/chooser/select_format.html | 2 +- .../templates/wagtailimages/images/add.html | 4 ++-- .../templates/wagtailimages/images/edit.html | 4 ++-- .../templates/wagtailimages/images/index.html | 2 +- .../templates/wagtailimages/multiple/add.html | 4 ++-- .../wagtailimages/multiple/edit_form.html | 4 ++-- .../templates/wagtailredirects/add.html | 2 +- .../templates/wagtailredirects/edit.html | 2 +- .../wagtailsearch/queries/chooser/chooser.html | 2 +- .../templates/wagtailsnippets/chooser/choose.html | 2 +- .../templates/wagtailsnippets/snippets/create.html | 4 ++-- .../templates/wagtailsnippets/snippets/edit.html | 4 ++-- .../wagtailsnippets/snippets/type_index.html | 2 +- .../templates/wagtailusers/groups/create.html | 2 +- .../templates/wagtailusers/groups/edit.html | 2 +- .../templates/wagtailusers/users/create.html | 4 ++-- .../templates/wagtailusers/users/edit.html | 4 ++-- 46 files changed, 72 insertions(+), 86 deletions(-) diff --git a/wagtail/contrib/modeladmin/templates/modeladmin/choose_parent.html b/wagtail/contrib/modeladmin/templates/modeladmin/choose_parent.html index 22054fbd2..59d20d0f3 100644 --- a/wagtail/contrib/modeladmin/templates/modeladmin/choose_parent.html +++ b/wagtail/contrib/modeladmin/templates/modeladmin/choose_parent.html @@ -25,7 +25,7 @@

{% blocktrans %}Choose a parent page{% endblocktrans %}

{% blocktrans with view.verbose_name_plural|capfirst as plural %}{{ plural }} can be added to more than one place within your site. Which of the following would you like to be the parent of your new page?{% endblocktrans %}

-
+ {% csrf_token %}