About Form Template Processor

Proof-of-concept module to let you use templates as web contact forms. Can send you email and/or save the submission to a page in your site.Intended to be a starting point and proof-of-concept, so you may want to take this further.

Category 1Other Modules
Modules that have a unique purpose not covered by existing categories.
Category 2Proof of Concept
Proof of concept modules are designed as examples or starting points for others to build from. May not be ideal for users wanting to plug-n-play.
Release StateBeta
Close to stable, but users are advised to be cautious and test thoroughly.*
Authorryan
Module Version1.0.1
Class NameFormTemplateProcessor
Compatibility2.0, 2.1, 2.2
Date AddedJuly 24, 2012
Recommended ByNew recommendations may take up to 1 day to appear.

Instructions

Installation
1. Place FormTemplateProcessor.module in your site/modules/ directory.
2. Login to ProcessWire admin and click to Modules.
3. Click "Check for new modules".
4. Click "install" next to the new FormTemplateProcessor module.

Usage
1. In admin, create the fields you want to be part of the form.
2. Create a new template and assign your fields to this template.
3. Create another template for your contact form page (if you don't already have one).
4. Use the example below as a starting point for this contact form page:

Code:
$form = $modules->get('FormTemplateProcessor');$form->template = $templates->get('my_contact_form_template'); // required $form->requiredFields = array('fullname', 'email'); $form->email = 'your@email.com'; // optional, sends form as email $form->parent = $page; // optional, saves form as page echo $form->render(); // draw form or process submitted form

5. Use CSS to style the fields. See below for a suggested starting point:
Code:
.Inputfields,.Inputfields li { list-style: none; margin: 1em 0; padding: 0; } .Inputfields li label { font-weight: bold; } .Inputfields li p { margin: 0; } .Inputfields li p.description { font-style: italic; } .Inputfields textarea, .Inputfields .InputfieldMaxWidth { width: 100%; } .Inputfields .InputfieldSubmit label { display: none; } .ui-state-error-text { color: red; }

README

ProcessWire FormTemplateProcessor module

Overview:
=========

Module to let you use templates as web contact forms.
Can send you email and/or save the submission to a page in your site.
Intended to be a starting point and proof-of-concept, so you may
want to take this further.

For more information:
http://processwire.com/talk/index.php/topic,75.0.html

Designed for use with ProcessWire 2.0 or 2.1
http://processwire.com

Installation:
=============

1. Place FormTemplateProcessor.module in your site/modules/ directory.
2. Login to ProcessWire admin and click to Modules.
3. Click "Check for new modules".
4. Click "install" next to the new FormTemplateProcessor module.

Usage:
======

1. In admin, create the fields you want to be part of the form.
2. Create a new template and assign your fields to this template.
3. Create another template for your contact form page (if you don't already have one).
4. Use the example below as a starting point for this contact form page:

$form = $modules->get('FormTemplateProcessor');
$form->template = $templates->get('my_contact_form_template'); // required
$form->requiredFields = array('fullname', 'email');
$form->email = 'your@email.com'; // optional, sends form as email
$form->parent = $page; // optional, saves form as page
echo $form->render(); // draw form or process submitted form

5. Use CSS to style the fields. See below for a suggested starting point:

.Inputfields,
.Inputfields li {
list-style: none;
margin: 1em 0;
padding: 0;
}

.Inputfields li label {
font-weight: bold;
}

.Inputfields li p {
margin: 0;
}

.Inputfields li p.description {
font-style: italic;
}

.Inputfields textarea,
.Inputfields .InputfieldMaxWidth {
width: 100%;
}

.Inputfields .InputfieldSubmit label {
display: none;
}

.ui-state-error-text {
color: red;
}



Comments

  • Andoro

    Andoro 3 years ago 10

    Dear Ryan!

    This is great, I was able to do a simple form with it.

    Question:

    If I have an "InputfieldPage" in my form, e.g. checkbox and radio, in the e-mail I see only the ID-s of the selected pages.

    How could I get the exact page title values, so the e-mail could be understandable?

    Thx a lot!

    • Simon

      Simon 2 years ago 00

      Hi Ryan and Andoro,

      +1 for that Problem. Has anyoune found a solution till now?

      Cheers

  • Patrick t.

    Patrick t. 2 years ago 10

    Hi Andoro and Simon, i think you can set the value of checbox or radio, using a filter to get all pages listed in form, and use their names or url.

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.