How to use form_overrides on ListField(StringField)?
laiyonghao opened this issue · 0 comments
laiyonghao commented
I have a WebPage
class to store pages scraped from web.
class WebPage(Document):
html = fields.StringField()
top_image = fields.StringField()
images = fields.ListField(fields.StringField())
... other fields.
I Defined a MyImageField
to display image fields.
from wtforms import StringField
from wtforms.widgets import Input
from flask import render_template
class MyImageInputWidget(Input):
def __call__(self, field, **kwargs):
return render_template(
"my_image_widget.html",
field=field,
)
class MyImageField(StringField):
widget = MyImageInputWidget()
It is very easy to use with top_image
field:
class WebPageModelView(ModelView):
form_overrides = {
'top_image': MyImageField,
}
It looks like
But how to use form_overrides
on images
field ?