# The Form Tag

The {exp:mandrill_mailer:form} tag pair is how you primarily interact with Mandrill Mailer. It outputs and submits the form, and if you specify an ajax response, it will return a success object for your javascript.

# Parameters

Tag Pair Parameters
allowed="phone|message" {!-- Required --}
to="janedoe@internet.com" {!-- Required if no "to-email" input --}
from="johndoe@internet.com" {!-- Required if no "from-email" input --}
subject="Cool Stuff Happening" {!-- Required if no "subject" input --}
from-name="John Doe" {!-- Can also be set with a "from-name"  input --}
required="phone|message" {!-- Specify required fields for this form --}
message="phone|message" {!-- Override the default of all fields being put in body --}
return="/my/uri" {!-- Redirect to new page on successful submission --}
json="yes" {!-- More below --}
class="my-class" {!-- Specify a class for the form tag --}
id="my-id" {!-- Specify an ID for the form tag --}
attr:my-attribute="my-data" {!-- Specify any attribute for the form tag --}
private_message="yes" {!-- Disables logging of email content in Mandrill --}


Output a JSON response object on form submission rather than returning the template HTML.

If the submission was successful, the object will contain "success": 1.

If submission was unsuccessful, the object will contain "success": 0, and if there are errors related to fields in the submission, they will be listed in the errors array as a list of field names.

	"success": 0,
	"errors": [

# Variables and Tags

{my-field-name} {!-- Content of posted field on error postback --}
{if error:my-field-name}has error{/if}
{if success}successful form submission{/if}
{if error}unsuccessful form submission{/if}

# Automatic Fields

Depending on the type of form you need, you may or may not wish to use the automatic fields available. These fields can be overridden by tag parameters, but if those tag parameters are not present, Mandrill Mailer falls back to these fields.

<input name=”from-email”>

If you wish to let the user specify a from email, give your input the name of from-email. This will automatically be set as the reply-to address.

<input name=”from-name”>

If you wish to let the user specify their name, set your input name to from-name. This will be set as the from name on the email.

<input name=”to-email”>

Lets the user specify the email recipient. Set your input name to to-email. Useful for “email a friend” forms. This will be set as the to email.

<input name=”to-name”>

Allow the user to specify the name of the recipient by setting this input name to to-name.

<input name=”subject”>

Allow the user to specify the subject by setting the input name to subject.

# Full Tag Pair Example

	subject="Cool Stuff Happening"

	{if success}
	{if:elseif error}
		Your submission did not go through, please check your info.

	<input type="text" name="from-name" placeholder="Your Name" value="{from-name}">
	{if error:from-name}Oops, you need a name!{/if}

	<input type="email" name="from-email" placeholder="Email Address" value="{from-email}">
	{if error:from-email}Oops, you need a email address!{/if}

	<input type="text" name="phone" placeholder="Phone Number" value="{phone}">

	<textarea name="content" placeholder="Message" value="{message}">
	{if error:content}Oops, you need to write something!{/if}

	<input type="submit">