Forum
Using template for contacts
Hi, I've created a content template to display staff details, this includes email addresses. What I'd like to do is not display the email address on the page and instead use the 'id' of the contact to grab the email address out of the database and use on a form to email the member of staff. What's the best approach?
How are you handling the form submission?
I was going to use normal php code to handle the forms as I have no experience of the forms add-on.
Content tags are parsed before form tags, so you should be able to generate the options of a form field using regular content tags.
Not sure what you mean Drew? I have a page that lists the staff and on that page I want a link like 'Send Jon a message' that contains the id of the person (contact.php?id=3 for example). This then loads the email address from the database and uses a form and php to send the message.
Ok, yes that would work.
Hi Drew, is it possible to dynamically set the to email address in the form add-on? I'd like to use the add-on using one form and passing an id, retrieving the email address as above, then setting the to email address in the form? Can this be done or am I best sticking with php?
Yes, you can do that - see the instructions in the sidebar when configuring the form options.
Hi Drew, not sure what you mean? How would you'd pass an email address retrieved from the database in the form options? Would like to use one staff form template and pass the email address when submitting the form not through the form options? Here's my form template...
I want to send the info entered using this form to different staff members depending on '_id' of the member of staff (passed to the page using a querystring).
The Forms app won't retrieve an email address from the database for you, but you can dynamically use any field in the form as per the instructions within the app.
I can't see anywhere in the instructions where it would allow you to dynamically change the to email address? Think we may have our wires crossed. To recap, I have a template that is used to enter staff details. I have a separate template that displays these details but doesn't display the email address. Instead there is a link that passes the id of the staff member to a contact page...
On the contact page I use a form. I can retrieve the email address using the id from the database what I'm struggling with is how I then change who receives the info when the form is submitted. I can see that you can change the to email address in the form options but what I can't see is how this could be changed dynamically? Thanks
The Forms app won't retrieve an email address from the database for you.
Okay. So if I wanted to use Perch CMS to store staff details and use an online form to send messages as described above what method would you recommend? Thanks
Are all the email addresses form the same domain?
Yes. The workaround I have in place at the moment is using php to send the message but I like the way the forms app stores content within the CMS.
So you can dynamically use any of the fields from the form to send to. If you put the username in the form as a hidden field, you can then send the form to, e.g.