Reputation: 777
I am using wagtail translations outlined here for some of my page models. They are working as expected. I am adding a form via the form builder I can access the forms via the url www.domain.com/slug but when I fill it out the url redirects to a None url. Also in the admin, if I click on the LIVE button, it directs to a None url as well.
I assumed it had to do with not being hooked up to the translations because, by default, that is adding a url slug for each language in the promote panel of a page. So I hooked up the form model to the translations and the content panels are getting the correct translations, but the promote panel still only receives a slug field. There is no other fields for the different languages.
The LIVE button still gives a None and when I submit the form on the page, it redirects to a None page with an error. Again, all my other pages that are hooked up with the translations work as expected.
I'm assuming the Wagtail forms don't fully support the translations. With internationalization like this, is it an all or nothing deal? I can't leave the forms outside of the translations situation?
Upvotes: 0
Views: 425
Reputation: 777
So after examining the issue more, I had to import Page into the AbstractEmailForm class in order to make it work. This is verbatim what is taken from the Wagtail docs and adding the Page in.
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
class FormField(AbstractFormField):
page = ParentalKey('FormPage', related_name='form_fields')
class FormPage(AbstractEmailForm, Page):
intro = RichTextField(blank=True)
thank_you_text = RichTextField(blank=True)
content_panels = AbstractEmailForm.content_panels + [
FieldPanel('intro', classname="full"),
InlinePanel('form_fields', label="Form fields"),
FieldPanel('thank_you_text', classname="full"),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('from_address', classname="col6"),
FieldPanel('to_address', classname="col6"),
]),
FieldPanel('subject'),
], "Email"),
]
Wagtail translations needs to use Page to change the URLS. This fixes the None issue.
Upvotes: 2