diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 75eb51bb1d..aa2e0f06c7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,7 +4,9 @@ Changelog 1.8 (xx.xx.xxxx) - IN DEVELOPMENT ~~~~~~~~~~~~~~~~ -* Added support of a custom `edit_handler` in site settings (Axel Haustant) + * Added support of a custom `edit_handler` in site settings (Axel Haustant) + * Added `get_landing_page_template` getter method to `AbstractForm` (Gagaro) + * Fix: `AbstractForm` now respects custom `get_template` methods on the page model (Gagaro) 1.7 (xx.xx.xxxx) - IN DEVELOPMENT diff --git a/docs/reference/contrib/forms.rst b/docs/reference/contrib/forms.rst index fbde6153e8..50ec655389 100644 --- a/docs/reference/contrib/forms.rst +++ b/docs/reference/contrib/forms.rst @@ -74,7 +74,7 @@ You now need to create two templates named ``form_page.html`` and ``form_page_la -``form_page_landing.html`` is a regular Wagtail template, displayed after the user makes a successful form submission. +``form_page_landing.html`` is a regular Wagtail template, displayed after the user makes a successful form submission. If you want to dynamically override the landing page template, you can do so with the ``get_landing_page_template`` method (in the same way that you would with ``get_template``). .. _wagtailforms_formsubmissionpanel: diff --git a/docs/releases/1.8.rst b/docs/releases/1.8.rst index eb0d4033a6..d68779c931 100644 --- a/docs/releases/1.8.rst +++ b/docs/releases/1.8.rst @@ -15,11 +15,14 @@ Minor features ~~~~~~~~~~~~~~ * Added support of a custom ``edit_handler`` for site settings. See :ref:`docs for the site settings module `. (Axel Haustant) + * Added ``get_landing_page_template`` getter method to ``AbstractForm`` (Gagaro) Bug fixes ~~~~~~~~~ + * ``AbstractForm`` now respects custom ``get_template`` methods on the page model (Gagaro) + Upgrade considerations ====================== diff --git a/wagtail/wagtailforms/models.py b/wagtail/wagtailforms/models.py index 9f33633fd1..fab52b5cb3 100644 --- a/wagtail/wagtailforms/models.py +++ b/wagtail/wagtailforms/models.py @@ -207,6 +207,9 @@ class AbstractForm(Page): return form_class(*args, **form_params) + def get_landing_page_template(self, request, *args, **kwargs): + return self.landing_page_template + def get_submission_class(self): """ Returns submission class. @@ -242,7 +245,7 @@ class AbstractForm(Page): # TODO: It is much better to redirect to it return render( request, - self.landing_page_template, + self.get_landing_page_template(request), self.get_context(request) ) else: @@ -252,7 +255,7 @@ class AbstractForm(Page): context['form'] = form return render( request, - self.template, + self.get_template(request), context ) @@ -265,7 +268,7 @@ class AbstractForm(Page): if mode == 'landing': return render( request, - self.landing_page_template, + self.get_landing_page_template(request), self.get_context(request) ) else: