Currently I'm using Flask with WTForms via Flask-WTForms but being stuck with FieldList. I use FieldList for a list of email address like this:
class MailToForm(Form):
emailAddress = StringField(
'Email',
validators=[
validators.DataRequired(),
validators.Email()
]
)
Then I have another form to use it above form:
class JobForm(Form):
name = StringField('Name',
validators=[
validators.DataRequired()
])
annotation = TextAreaField('Annotation')
emails = FieldList(FormField(MailToForm),
'Send Result To',
min_entries=1)
The problem here is that when I submit the form with all valid data the validate_on_submit
function won't return True
if I not pass a new Optionals
validation for emails
field in JobForm
. But then the form will valid event if I pass invalid data to emailAddress
.
Please help me on this!
I got how to get away with this. I have to add the WTF's hidden fields of subforms so it can be validated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.