Forum

Thread tagged as: Question, Forms

Multiple forms

I have numerous pages with forms that look exactly the same but go to different people.

Can i use one form template but be able to assign a different recipient at page level?

John Robinson

John Robinson 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You could put the fields in a sub template and just have the <perch:form> tags with the form's unique ID in the unique templates.

I changed form content template to have the fields in a sub template - think this works. How do i make id="conatct" changeable? When i create the pages using a master page how do i make the perch:form id editable so i can assign a unique id's when making a page? Thanks

<perch:form id="contact" method="post" app="perch_forms">

<perch:template path="content/location-form-fields.html" />
<!--<perch:content id="intro" type="textarea" label="Intro" textile="true" editor="markitup" size="m" />

<div>
    <perch:label for="name">Name</perch:label>
    <perch:input type="text" id="name" required="true" label="Name" />
    <perch:error for="name" type="required">Please add your name</perch:error>
</div>

<div>
    <perch:label for="email">Email</perch:label>
    <perch:input type="email" id="email" required="true" label="Email" placeholder="you@company.com" />
    <perch:error for="email" type="required">Please add your email address</perch:error>
    <perch:error for="email" type="format">Please check your email address</perch:error>
</div>

<div>
    <perch:label for="message">Message</perch:label>
    <perch:input type="textarea" id="message" required="true" label="Message" />
    <perch:error for="message" type="required">Please add a message</perch:error>
</div>

<div>
    <perch:input type="submit" id="submit" value="Send" />
</div>

<perch:success>
<perch:content id="success" type="textarea" label="Thank you message" textile="true" editor="markitup" />
</perch:success>-->
</perch:form>
Drew McLellan

Drew McLellan 2638 points
Perch Support

The ID needs to be hardcoded into the template - there's no way around that.

I see thanks, this approach probably wouldn't save time.

Please could you advise if this could this work..?

I create all the pages using the same master with a region where form code is inserted, within this code I manually specifiy a php form file to send to and manually create this.

In the form files which are posted to, there is a section where the reciepient email addresses are assigned, could this section be a perch region which I could set in the admin. The code where email addresses are assigned is within a php tag.

*/

$my_email = "paul@thedesignbank.co.uk";

/* 
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, if you were going to send the email yourself.

Are they email address all on the same domain? If so, you could specify the user in a hidden field in the template then send to the address dynamically, I think.

Hi Drew,

I just used mine as a demo, the email address could be any domain. I think i'll have to a certain amount manually but thanks for your assistance.