\ContactForm
Builds a simple contact form with spam protection.
Integrates with Postmark <http://www.postmarkapp.com>
to send emails externally.
Integrates with BootstrapForm when available.
Note: Despite its name, this class does not create a object. Rather,
it is a proxy set of controls for a . This is mostly because the form
can transform into a BootstrapForm object at runtime.
Because this class serves as a proxy to a form, it is necessary to return the object to the template
with the ->render() method.
ex.
return ContactForm::create("MyForm", "you@example.com","Subject of message")
->addField(TextField::create("YourName","Your name"))
->render();
- Author: Aaron Carlino <aaron@bluehousegroup.com>
Synopsis
class ContactForm
extends Object
{
- // members
- protected static boolean $use_bootstrap = true;
- protected static boolean $use_postmark = true;
- protected static boolean $jquery_included = false;
- protected static boolean $jquery_validation = true;
- protected static $default_spam_protection;
- protected $useBootstrap = NULL;
- protected $usePostmark = NULL;
- protected $toAddress = NULL;
- protected string $replyToField = "Email";
- protected $replyTo;
- protected $messageSubject = NULL;
- protected array $validation = ;
- protected $formName = NULL;
- protected Form $form = NULL;
- protected array $spamProtection = ;
- protected function $onBeforeSend;
- protected function $onAfterSend;
- protected $successURL;
- protected $successMessage = NULL;
- protected string $emailTemplate = "ContactPageEmail";
- protected array $omittedFields = ;
- protected string $emailIntroText = "";
- // methods
- public static void set_use_bootstrap()
- public static void set_jquery_included()
- public static void set_jquery_validation()
- public static void set_default_spam_protection()
- public static string create_name_from_label()
- public void __construct()
- public ContactForm addField()
- public ContactForm addOmittedField()
- public ContactForm addRequiredField()
- public void setRequiredFields()
- public void setRequiredField()
- public ContactForm addFields()
- public boolean isBootstrap()
- public boolean isPostmark()
- public ContactForm addFromString()
- public ContactForm setUseBootstrap()
- public Form getForm()
- public ContactForm setSpamProtection()
- public array getSpamProtection()
- public ContactForm addSpamProtector()
- public ContactForm setOnBeforeSend()
- public function getOnBeforeSend()
- public ContactForm setOnAfterSend()
- public function getOnAfterSend()
- public string getSuccessURL()
- public ContactForm setSuccessURL()
- public ContactForm setSuccessMessage()
- public string getSuccessMessage()
- public ContactForm setToAddress()
- public string getToAddress()
- public ContactForm setMessageSubject()
- public string getMessageSubject()
- public ContactForm setEmailTemplate()
- public string getEmailTemplate()
- public ContactForm setReplyToField()
- public ContactForm setReplyTo()
- public array getOmittedFields()
- public string getReplyTo()
- public ContactForm setIntroText()
- public string getIntroText()
- public ContactForm updateValidation()
- protected string getValidationJS()
- public Form render()
Hierarchy
Extends
- Object
Members
protected
- $default_spam_protection — array
- $emailIntroText — string
- $emailTemplate — string
- $form — Form
- $formName — string
- $jquery_included — boolean
- $jquery_validation — boolean
- $messageSubject — string
- $omittedFields — array
- $onAfterSend — function
- $onBeforeSend — function
- $replyTo — string
- $replyToField — string
- $spamProtection — array
- $successMessage — string
- $successURL — string
- $toAddress — string
- $useBootstrap — boolean
- $usePostmark — boolean
- $use_bootstrap — boolean
- $use_postmark — boolean
- $validation — array
Methods
protected
- getValidationJS() — Gets the JavaScript to use with jQuery validation
public
- __construct() — Constructor function for the ContactForm
- addField() — Adds a field to the contact form
- addFields() — Adds a list of fields to the form. Accepts an arbitrary number of arguments.
- addFromString() — Adds a form field given a string, e.g. "What is your name?//Text"
- addOmittedField() — Adds an omitted field to the list
- addRequiredField() — Adds a required field to the form
- addSpamProtector() — Adds a {@link ContactFormSpamProtector} object to the form
- create_name_from_label() — A utility method that creates a label from a form field name
- getEmailTemplate() — Gets the template to use for the email
- getForm() — Gets the {@link Form} object that this object is managing
- getIntroText() — Gets the intro text for the email
- getMessageSubject() — Gets the subject of the email
- getOmittedFields() — Gets the fields to omit from the email
- getOnAfterSend() — Gets the function to call after the form sends
- getOnBeforeSend() — Gets the function to call before sending the form
- getReplyTo() — Gets the reply-to email address given the dynamic and hard-coded options
- getSpamProtection() — Gets the spam protection list
- getSuccessMessage() — Gets the success message for the form
- getSuccessURL() — Gets the URL to redirect to after form is successfully submitted
- getToAddress() — Gets the address to which the form will be sent
- isBootstrap() — Given the global setting and instance level setting, determine if this form will use BootstrapForm
- isPostmark() — Given the global and instance-level settings, determine if this form will use Postmark
- render() — Renders the {@link Form} object that is managed by the ContactForm.
- setEmailTemplate() — Sets the template to use for the email
- setIntroText() — Sets the text to display in the email before all the form data
- setMessageSubject() — Sets the subject of the email
- setOnAfterSend() — Sets an anonymous function to call after the form sends
- setOnBeforeSend() — Adds an anonymous function to call before the form sends
- setReplyTo() — Sets a hard-coded reply-to email address
- setReplyToField() — Sets the field to use for for dynamic reply-to
- setRequiredField()
- setRequiredFields()
- setSpamProtection() — Sets the list of {@link ContactFormSpamProtector} objects to use on this form
- setSuccessMessage() — Sets the message to display when the form is successfully submitted
- setSuccessURL() — Sets the URL to redirect to after form is successfully submitted
- setToAddress() — Sets the email address to which the form will be sent
- setUseBootstrap() — Sets the form to use or not use Boostrap. If the form is already created, make sure to create a new one if the class is different
- set_default_spam_protection() — Sets the default spam protection
- set_jquery_included() — Sets the global setting that jQuery is included
- set_jquery_validation() — Sets the global setting that jQuery validation is included
- set_use_bootstrap() — Sets the global setting to use or not use BootstrapForm when available
- updateValidation() — Updates the validation for a given field by merging new settings with old