Originally developed by Raymond Irving (15-Dec-2004)
Version 1.3 - 1.4 extended by: Jelle Jager (TobyL) September 2006
Captcha image support - thanks to Djamoer
Multi checkbox, radio, select support - thanks to Djamoer
Styles (for these docs) 'borrowed' from Adam Crownoble's QuickEdit
eForm converts a web form into an email which can be sent via email to specified users. Its main features are: html form mail with attachments, auto-respond, report generation using placeholders and extended form validation.
&eformOnBeforeFormParse (triggered as soon as templates are loaded)&eFormOnFormValidate (triggered after eForm validation has occurred)&eFormOnBeforeFormMerge (triggered when and before form is displayed)&eFormOnBeforeFormParse (triggered after template(s) are loaded and before they are parsed)
You can see a more extensive version history here.
eForm is very flexible and there's quite a collection of parameters you can use to get eForm to do what you want. Read some of the examples if you're unsure what to do.
<input type="hidden" name="formid" value="formName" />or (in eForm 1.4:final) you can set the the id in the form tag itself:
<form id="formName"...>&tplplus [+fieldname+], where fieldname stands for the name of each form field you wish to include.&emailbut for Cc:&emailbut for Bcc:&toparameter. This selector field will act like a numeric
index to select an email. It will start at 1 for the first email
and ends at N for the last email in the list.&to =`sales@me.com,support@me.com,billing@me.com`
&mailselector=`topic`&toparameter. This email address will be the address used to send the email to.[.firstname.]&tpl&thankyou[!eForm &sessionVars=`jobID` ... !]and
<input type="hidden" value="[+jobID+]" />&sessionVars. Normally session variables will overide posted values. By setting &postOverides=`1` posted values will take precedence.The eForm event functions are now incorporated into the parameters. They are:
[!eForm?
&to=`me@mydomain.com`
&gotoid=`1`
&tpl=`orders`
&report=`orderreport`
!]
[!eForm?
&to=`sales@mysuppliers.com`
&category=`Purchase Order`
&tpl=`chunkPurchaseOrder`
&report=`chunkPurchaseReport`
!]
For all normal form fields eForm automatically inserts appropriate placeholders. However there are a few that you may need to add manually:
[+validationmessage+] - This should be somewhere in your form template. It is used for any validation error messages (suprise, suprise...)[+vericode+] & [+verimageurl+] - These are needed in the form if you want to use the CAPTHCA code. See the Examples on how to use these.[+postdate+] - This placeholder can be used in reports and in the thankyou template and will be filled with the current date and time (date on the server that is)[+debug+] - From version 1.4.1 this is automatically placed (if debug is on) in the form and thankyou template. It is not automatically placed in the report template! This is to avoid any server side information to accidentally be sent out via email. If you need debug info in test emails you will have to add this placeholder in the report template yourself.eForm is incorporating a form parser which extracts formatting and validation options from each form field. To set options for a field add the
eform(pseudo) attribute to each required form field.
<input type="text" name="color" eform="A Color:string:1" />
The basic format of the eform attribute is:
[description/title]:[datatype]:[required]:[validation message]:[validation rule]
You only need to set the following data types. Others will be set automatically (radio & checkbox as they are, string for textbox and listbox for select)
Standard validation: All fields that are required will be checked if they are left empty.
The listbox, checkbox and radio fields do normally not require the datatype to be set. eForm will recognize these automatically. It will validate the values against the list of values placed in the form.
This version instroduces extended server validation and word filtering using very flexible validation rules that can be set in teh
eformattribute. You can set 2 extra validation parameters, a custom error message and a validation or filter rule.
example:
eform="Year of Birth:integer:1:Must be between 1950 and 2002:#RANGE 1950-2002"
#LIST blue,red,green.maroon#RANGE 1,3,-5~-15,60~82{DBASE}
{PREFIX}tags which will be replaced by the MODx database name and table prefix respectively.#SELECT keyword FROM {PREFIX}site_keywords#FUNCTION myValidationFunction#REGEX /^[a-z]+ [a-z0-9_]+/i#FILTER #LIST badword,verybadword||goodword,verygoodword#FILTER #EVAL return myFilterFunction($value);function myFilterFunction($value){
$badWords = array('scribble','coding');
$goodWords = array('design','sleep');
return str_replace($badWords,$goodWords,$value);
}Select boxes, radio options and checkbox fields now have working automatic validation. Any input for these fields is validated against the values set in your form template. This avoids anyone tampering with the form by adding their own values to these fields
By default hidden fields are validated as a protection against tampering by comparing the input against the value set in the form template (much like the select, checkbox and radio fields) In some circumstances this may not be desirable however. For instance when you use some javascript in your form to store a result in a hidden field. In those cases you can turn this behaviour off by setting the eform attribute (with or without it's own validation).
Hidden field example 1.
The default behaviour is handy for instance if you are storing a document id and want to be sure
no one can tamper with the id. the field would look like this:
<input type="hidden" name="docId" value="31" />
Hidden field example 2.
Suppose you have a form where a javascript calculated value is stored in a hidden field. To avoid the hidden
field being validated at all you add the following eform attribute:
<input type="hidden" name="calculatedField" value="" eform="::0::" />
Hidden field example 3.
Same scenario as 2 but suppose you want to make sure a value is returned and that it stays within a certain
range. The eform attribute is set with: title,integer data type, required field, error message
and validation with #RANGE (in this example a value between 1-10)
<input type="hidden" name="calculatedField" value="" eform="Calculated Value:integer:1:Calculation out of range:#RANGE 1-10" />
1. Selectbox - set as required field (no validation required)
2. Textbox - required and format set to date
3. Multiple checkbox - required, eform_options only set once.