-
-
Save lb-/a3c6b8c0c3f2f0fd2574ed8cc29afd94 to your computer and use it in GitHub Desktop.
from wagtail.wagtailforms.forms import FormBuilder | |
from wagtail.wagtailimages.fields import WagtailImageField | |
class ExtendedFormBuilder(FormBuilder): | |
def create_image_upload_field(self, field, options): | |
return WagtailImageField(**options) | |
FIELD_TYPES = FormBuilder.FIELD_TYPES | |
FIELD_TYPES.update({ | |
'image': create_image_upload_field, | |
}) |
@ChiragKanzariya - the internal set up of FormBuilder
has changed somewhat since this was written.
But the source code for that class can be seen here:
https://github.com/wagtail/wagtail/blob/master/wagtail/contrib/forms/forms.py#L103
Note that FIELD_TYPES is no longer a static attribute on FormBuilder but instead there is a property
called formfields
which could be overridden to add the 'image' type field.
I have not really had the chance to update/re-write the blog post with the new internal workings in mind, but hope that helps.
Hi @ChiragKanzariya - I don't have an updated example sorry but you can view all the Wagtail source code on their repo.
@ChiragKanzariya - awesome, if you don't mind, can you share the repo (if on github) or paste the relevant part of your code here.
This will help me and others work through this in the future, plus helps me if I get the time to write a new blog post about this.
How FIELD_TYPES attribute imported from FormBuilder?
Because it's shows me that FormBuilder has no attribute FIELD_TYPES @lb (Ben Johnston)