I'm trying to build a form with dynamic fields (click a plus to add extra
fields).
forms.py:
class ActionForm(Form):
key = SelectField("Type: ", coerce=int, choices=[(0, "Option 1"),
(1, "Option 2"), (2, "Opeion 3")], default=0)
value = StringField('Value: ')
class EditForm(Form):
content = StringField("Content: ")
actions = FieldList(FormField(ActionForm))
status = RadioField("Status: ", coerce=int, choices=[(0,
"Inactive"), (1, "Active")], default=1)
submit = SubmitField("Submit")
View Template (Won't Render the Fields from my ActionForm):
<form method="POST">
{{ form.csrf_token }}
{{ form.actions.label }}
<div class="form-group input-group">
{% for action in form.actions %}
{% for field in action %}
{{ field() }}
{% endfor %}
{% endfor %}
</div>
{{ form.status.label }}{{ form.status }}
{{ form.submit() }}
</form>
Problem:
In my form, I just see a blank spot where the "subfields" should appear
For some reason, I can't iterate through `form.actions` (to show the
SelectField() and StringField()).
What am I doing wrong?
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.