Reputation: 1847
I'm using the Wagtail Form Builder so that site implementers can extend to create their own FormPage type with their own site-specific templates.
I want to render all form pages on a parent page; this includes all child page fields, such as the title, as well as the full child form.
Ideally, the submit button should also act on a per-form basis.
Here's what I've tried:
<ul>
{% for child in page.get_children %}
<li>
<h5 class=>{{ child.specific.title }}</h5>
<div>
{{ child.specific.intro|richtext }}
<div id="form-holder">
<form action="{% child.pageurl page %}" method="POST">
{% csrf_token %}
{{ child.specific.form.as_p }}
<input type="submit">
</form>
</div><!-- contact-form-holder-->
</div>
</li>
{% endfor %}
</ul>
My form models are more or less as per the Form Builder documentation with a few extra fields:
class FormField(AbstractFormField):
db_table = 'form_field'
page = ParentalKey('FormPage', related_name='form_fields')
class FormPage(AbstractEmailForm):
db_table = 'form_page'
header = models.CharField(max_length=250)
intro = RichTextField(blank=True)
thank_you_text = RichTextField(blank=True)
content_panels = AbstractEmailForm.content_panels + [
FormSubmissionsPanel(),
FieldPanel('intro', classname="full"),
FieldPanel('header'),
InlinePanel('form_fields', label="Form fields"),
FieldPanel('thank_you_text', classname="full"),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('from_address', classname="col6"),
FieldPanel('to_address', classname="col6"),
]),
FieldPanel('subject'),
], "Email"),
]
I've found that I can render the child page fields such as title and intro if I use the .specific
method.
However, I can't seem to get any of the form to render; with or without the .specific
tag.
Any help would be very welcome!
Upvotes: 0
Views: 413
Reputation: 281
Off topic but maybe of any help:
{% for child in page.get_children %}
can be replaced by:
{% for child in page.get_children.specific %}
Upvotes: 0