This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from wagtail.wagtailforms.models import AbstractFormField, FORM_FIELD_CHOICES | |
| class FormField(AbstractFormField): | |
| FORM_FIELD_CHOICES = list(FORM_FIELD_CHOICES) + [('image', 'Upload Image')] | |
| field_type = models.CharField( | |
| verbose_name=_('field type'), | |
| max_length=16, | |
| choices=FORM_FIELD_CHOICES) | |
| page = ParentalKey('FormPage', related_name='form_fields') |
NewerOlder