Form Processor

Description:
The FormProcessor snippet will process almost any HTML form. The submitted data can be emailed or saved to a database (there is currently no simple method to view data that is saved in the database but it should be coming soon).

Requirements:
MODx CMS 0.9.1

Download:
FormProcessor snippet

Installation:

Usage (Snippet):
The FormProcessor snippet must be called from within the content of a document, like so

[!FormProcessor? &form_chunk=`ExampleForm` &data_email_address=`your_email@your_domain.com` &form_required=`Name,Message`!]
(Replace value names in backticks with corresponding values. form_name is required)

[ExampleForm] is the name of the chunk that contains the HTML for the form. [your_email@your_domain.com] is the email address where you want the form submissions sent. [Name,Message] is a comma-separated list of form input names for required fields.

Usage (ExampleForm Chunk):

To create a form to use with the FormProcessor you'll have to put the HTML for the form in a new chunk. An example form is provided below


<form action="[~[*id*]~]" method="post">
 <input type="hidden" name="send_to" value="FormProcessor" />

 <div>
  <label>Your Name</label> [+Name-required_message+]<br />
  <input type="text" class="[+Name-required_class+]" name="Name" value="[+Name-value+]" />
 </div>

 <div>
  <label>Your Choice</label><br />
  <select name="Choice">
   <option [+Choice-selected-door_1+]>Door #1</option>
   <option [+Choice-selected-door_2+]>Door #2</option>
  </select>
 </div>

 <div>
  <label>Your Message</label> [+Message-required_message+]<br />
  <textarea class="[+Message-required_class+]" name="Message">[+Message-value+]</textarea>
 </div>

 <div>
  <button type="submit">Send</button>
 </div>

</form>

There are five types of placeholders that are registered when a form is submitted but all required fields were not filled.

Any form you want processed by the form_processor will have to have a hidden input with the name send_to and the value FormProcessor, other wise the submission will be ignored by the snippet.

Names that are given to <input> tags should have underscores (_) in the place of spaces. Spaces will be substituted for underscores before the names are stored in the database or sent in an email.

The checked and selected placeholders contain the value of the option tag after the last dash. To reference these values in a placeholder you'll need to replace spaces with underscores (_) and remove anything that is not a letter, number or underscore.

Example:

Example Form

Support:

If you have any questions, problems or feature requests, please search the MODx forums as your request may have already been addressed there. If you did not find what you were looking for in the forms you can post a new topic there or contact me directly.