Using Wagtail's rich text widget for simple form?

14 views Asked by At

I created and registered a very simple email form for the Wagtail admin site without an underlying model:

class EmailForm(forms.Form):
    subject = forms.CharField(label='Betreff', max_length=100)
    body = forms.CharField(label='Nachricht', widget=forms.Textarea)

Now I would like to use Wagtail's rich text widget for the message body, so I did this:

from wagtail.admin.rich_text import DraftailRichTextArea

class EmailForm(forms.Form):
    subject = forms.CharField(label='Betreff', max_length=100)
    body = forms.CharField(label='Nachricht', widget=DraftailRichTextArea)

The widget is initialized, but an error is raised in the browser:

TypeError: undefined is not an object (evaluating 'window.draftail.initEditor')

What would I need to add to use the Draftail widget, and how can I transform the field's content to regular HTML in the view before sending the message (i.e. outside of a template)?

Thanks, Jan

0

There are 0 answers