Forum
Unable to Submit 2 Forms in Same Template File
Hi all,
I currently have the following in a content template file...
<div class="col-xs-12 col-sm-4 middle">
<h2><i class="fa fa-angle-double-right" aria-hidden="true"></i><perch:content id="downloadH2" type="text" label="H2 title" /></h2>
<h3><perch:content id="downloadH3" type="text" label="H3 title" /></h3>
<img src="<perch:content id="downloadImg" type="image" label="Brochure image" />" alt="<perch:content id="downloadH3" />" />
<perch:form id="download" method="post" app="perch_forms">
<div class="form-field">
<perch:label for="nameDownload" class="sr-only">Enter Your Name</perch:label>
<perch:input type="text" id="nameDownload" required="true" label="Name" placeholder="Enter Your Name" />
</div>
<div class="form-field">
<perch:label for="emailDownload" class="sr-only">Enter Your Email</perch:label>
<perch:input type="text" id="emailDownload" required="true" label="Email" placeholder="Enter Your Email" />
</div>
<div class="text-center">
<div class="btn-blue">
<perch:input type="submit" value="Yes Please" />
</div>
</div>
<perch:success>
<div class="alert alert-success" role="alert">
<h3><i class="fa-li fa fa-angle-double-right" aria-hidden="true"></i> Thank You</h3>
<a href="<perch:content id="alertDownload" type="file" label="Brochure PDF" bucket="docs" />" target="_blank">Click here to download our brochure</a>
</div>
</perch:success>
</perch:form>
</div>
<div class="col-xs-12 col-sm-4 right">
<h2><i class="fa fa-angle-double-right" aria-hidden="true"></i><perch:content id="newsletterH2" type="text" label="H2 title" divider-before="Newsletter Column" /></h2>
<h3><perch:content id="newsletterH3" type="text" label="H3 title" /></h3>
<img src="<perch:content id="newsletterImg" type="image" label="Newsletter image" />" alt="<perch:content id="newsletterH3" />" />
<perch:form id="newsletter" method="post" app="perch_forms">
<div class="form-field">
<perch:label for="nameNewsletter" class="sr-only">Enter Your Name</perch:label>
<perch:input type="text" id="nameNewsletter" required="true" label="Name" placeholder="Enter Your Name" />
</div>
<div class="form-field">
<perch:label for="emailNewsletter" class="sr-only">Enter Your Email</perch:label>
<perch:input type="text" id="emailNewsletter" required="true" label="Email" placeholder="Enter Your Email" />
</div>
<div class="text-center">
<div class="btn-blue">
<perch:input type="submit" value="Sign Me Up" />
</div>
</div>
<perch:success>
<div class="alert alert-success" role="alert">
<ul class="fa-ul">
<li>
<i class="fa-li fa fa-angle-double-right" aria-hidden="true"></i>
<perch:content id="alertNewsletter" type="textarea" editor="redactor" html="true" label="Newsltter signup success message" />
</li>
</ul>
</div>
</perch:success>
</perch:form>
</div>
...unfortunately, I can't get both forms to work.
If I remove the second form id="newsletter"
the first form id="download"
works and submits perfectly, add the second form back in and the first form doesn't work (takes me staight back to the same page on submit) but the second form does work.
I have checked for duplicate IDs and they all seem fine.
Knowing me it's something pretty simple and I've been looking at it too long to notice the mistake.
Many thanks
Glen
Can you show me what HTML output you get?
Hi Drew, here you go...
That looks like it should be fine - everything is being properly prefixed by Perch.
What does debug output when the submission fails?
Hi Drew,
The page debug on index.php after the form
id="download"
has been submitted looks like this...I don't know if this is helpful within the debug...
...as that's the 2 fields on the second
id="newsletter"
form which is the other form that wasn't submitted?That's very helpful, thanks. It looks like there's a bug there somewhere. We should only be running validation on the form that was submitted.
I've managed to fix it so it should be fine in future versions.
For now, are you able to split your forms into two templates?
Thanks Drew - glad it's helped.
Yes, I've split the 2 forms into 2 different content templates and they're both working fine.
Glen