As the title says, here's what I've got:
form = F(obj = myobject)
myfieldlist= FieldList(FormField(form))
{% for subfield in form.myfieldlist %}
{{ subfield.field }}
{{ subfield.label }}
{% endfor %}
This outputs nothing, any ideas? Also, not entirely sure if FormField is required. Thanks
FormField
takes a class not an instance:
class GuestForm(Form):
email = TextField()
vip = BooleanField()
class VenueForm(Form):
name = TextField()
guests = FieldList(FormField(GuestForm))
Then in your controller:
form = VenueForm(obj=myobject)
render("template-name.html", form=form)
In your template you will need to iterate over the FieldList field as if it was its own form:
{% for guest_form in form.guests %}
<ul>
{% for subfield in guest_form %}
<li>{{ subfield.label }} {{ subfield }}</li>
{% endfor %}
</ul>
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With