| Current Path : /var/www/element/data/element_backup.2025.12.07/vsl-gates.ru/assets/snippets/eform/docs/ |
| Current File : /var/www/element/data/element_backup.2025.12.07/vsl-gates.ru/assets/snippets/eform/docs/eform.htm |
<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>eForm</title><style type="text/css">*{
font-family:arial, helvetica, sans-serif;
font-size:10pt;
border-width:1px;
border-color:#003399;
}
body{
background-color:#a4d1f9;
}
h1, h2, h3{
margin-bottom:0;
color:#003399;
}
h1{
margin-top:0;
margin-bottom:20px;
font-size:20pt;
text-align:center;
border-bottom-style:solid;
border-color:#e78900;
}
h2{
font-size:12pt;
}
hr{
color:#ffffff;
border-style:none none solid none;
border-color:#e78900;
}
p{
margin-top:0;
}
ul{
margin:0 0 0 10px;
padding:0;
list-style-type:square;
}
code{
font-family:monospace;
color:#666666;
}
a{
color:#e78900;
text-decoration:none;
}
a:hover{
border-bottom-style:dashed;
}
#qe_logo{
float:right;
margin:0 57px 20px 57px;
}
#qe_toc{
width:200px;
margin:0 0 20px 20px;
padding:20px;
float:right;
clear:right;
border-style:solid;
background-color:#eaf9ff;
}
#qe_toc h1{
margin-top:0;
font-size:12pt;
text-align:center;
}
div.qe_box{
margin:30px;
padding:30px;
border-style:solid;
background-color:#ffffff;
}
div.qe_level_2{
margin-left:20px;
}
.qe_salutation{
margin-left:30px;
}
.qe_signature{
font-family:cursive;
font-size:14pt;
}
.qe_param_list li{
margin:2px;
color:#333;
}
.qe_param_list li strong{
color:#036;
font-size:1.02em
}
.new{
color:#c00;
font-weight:bold;
}</style>
</head>
<body>
<div class="qe_box"><h1>eForm - The Electronic Form Snippet </h1><img id="qe_logo" src="logo.png" alt="logo" border="0" title="" />
<div id="qe_toc"><h1>Index</h1>
<ul>
<li><a href="eform.htm#top">Who's responsible</a></li>
<li><a href="eform.htm#what">What is eForm</a></li>
<li><a href="eform.htm#whatsnew">What' New</a></li>
<li><a href="eform.htm#installation">Installation</a></li>
<li><a href="eform.htm#params">Snippet Parameters</a></li>
<li><a href="eform.htm#events">Events</a></li>
<li><a href="eform.htm#placeholders">Placeholders</a></li>
<li><a href="eform.htm#datatypes">Data types</a></li>
<li><a href="eform.htm#validation">Extended Form Validation</a></li>
<li><a href="eform_examples.htm">Examples</a></li>
</ul>
</div>
<div class="qe_level_1"><h2>Who's responsible for eForm</h2>
<p>Originally developed by Raymond Irving (15-Dec-2004)<br/>Version 1.3 - 1.4 extended by: Jelle Jager (TobyL) September 2006</p>
<p>Captcha image support - thanks to Djamoer<br/>Multi checkbox, radio, select support - thanks to Djamoer<br/>Styles (for these docs) 'borrowed' from Adam Crownoble's QuickEdit</p>
</div>
<div class="qe_level_1"><h2>What is eForm?</h2>
<p>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.</p>
</div>
<div class="qe_level_1"><a name="whatsnew"></a>
<h2>What's New</h2>
<div class="qe_level_2">
<h3>Version 1.4.4</h3>
<ul>
<li>Fixed various Select box inconsistencies</li>
<li>Adjusted email validation expression to allow + character.</li>
<li>Line breaks in 'Html' fields will only be replaced in report template if &sendAsText false!</li>
<li>Line breaks in 'Html' fields will be replaced in thankyou template when &sendAsText is true</li>
<li>Properly display session hash name in debug text for &protectsubmit code</li>
<li>Properly escape regular expression in form parser</li>
<li>Fixed 0 (zero) values not being processed in form parser for validating select boxes</li>
<li>Fixed ambiguous variable naming in validation code</li>
<li>Enhanced efLoadTemplate function to also allow snippets as templates</li>
<li>&invalidClass now also works for vericode field</li>
<li>Added &autoSenderName parameter</li>
<li>Added &runSnippet parameter - Call a snippet before main form processing. See parameter documentation for details.</li>
<li>Added &snipFolder parameter for those that want to keep different versions of eform in different folders.
defaults to "eform".</li>
<li>Added $lang['ef_mail_error'] to the language file and a slightly improved error reporting when sending mail fails</li>
<li>Date formatting for report can now be set in language file: $_lang['ef_date_format']</li>
<li>Report output is now more locale aware as far as numbers are concerned. Added $_lang['ef_thousands_separator'] to the language file. If set to an empty string (default) the character defined in the current (php) locale will be used (if any).</li>
</ul>
<p><br />You can see a more extensive <a href="eform_history.htm">version history here</a>. </p>
</div>
</div>
<div class="qe_level_1"><a name="installation"></a>
<h2>Installation</h2>
<div class="qe_level_2">
<ul>
<li>Unzip the zip file into the assets/snippet/ folder. You should now have an extra folder called eform.</li>
<li>Create a new snippet, name it eForm and copy and paste the content of the eform.snippet.tpl file</li>
<li>Start reading this file and the examples</li>
<li>Create forms</li>
</ul>
</div>
</div><a name="params" id="params"></a>
<div class="qe_level_1"><h2>Snippet Parameters</h2>
<p>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 <a href="eform_examples.htm">examples</a> if you're unsure what to do.</p>
</div>
<div class="qe_level_2"><h4>Required parameters</h4>
<ul class="qe_param_list">
<li><strong>&formid</strong><br/>This is a unique id used to identity a form during postbacks. This is useful in cases where more than one form exists on a page.
Your form template should either have a hidden field with the same formid
<code><input type="hidden" name="formid" value="formName" /></code> or (from eForm 1.4.x) you can set the the id in the form tag itself:
<code><form id="formName"...></code>;</li>
<li><strong>&tpl</strong><br/>chunk name (non-numeric) or document id (numeric) to use as a form template <span class="new">(new in 1.4.4)</span> You can now also use a snippet as the template source. No parameters are forwarded to the snippet call in this version.
For the regular form fields you do not normally need to add placeholders, they automatically get inserted by eForm. The esception to this rule are in the case of event functions where you want to set specific values. Special placeholders available are:
[+validationmessage+], [+postdate+],[+verimageurl+] & [+debugText+]. You should have the [+validatiomessage+] placeholder in all your forms. The others you may need depending on other parameters.</li>
<li><strong>&report</strong><br/>chunk name (non-numeric) or document id (numeric) to use when generating reports.
Tags: Same as for
<code>&tpl</code>plus [+fieldname+], where fieldname stands for the name of each form field you wish to include.</li>
</ul><h4>Optional parameters</h4>
<ul class="qe_param_list">
<li><strong>&to</strong> (Optional)<br/>Email address to send eForm information to
For multiple recipients separate emails with a comma (,)
If omitted the site settings email address will be used</li>
<li><strong>&from</strong> (Optional)<br/>Sets the email address to appear in the From section of the email</li>
<li><strong>&fromname</strong> (Optional)<br/>Sets the name of the sender in the From section of the email</li>
<li><strong>&replyto</strong> (Optional)<br/>Email address or fieldname containing email address
Sets the email address to appear in the ReplyTo section of the email</li>
<li><strong>&sendirect</strong> (Optional)<br/>This will use the form field called email to supply the
email address to send the message to.
Set to 1 to activate send direct. Defaults to 0</li>
<li><strong>&cc</strong> (Optional)<br/>Same as
<code>&email</code>but for Cc:</li>
<li><strong>&bcc</strong> (Optional)<br/>Same as
<code>&email</code>but for Bcc:</li>
<li><strong>&ccsender</strong> (Optional)<br/>Set to 1 to send the user a copy of the submitted form. Defaults to 0
eForm will look for the user's email address inside a field called email.</li>
<li><strong>&subject</strong> (Optional)<br/>Subject to appear in email
Can include [.form fields.]. E.g. Purcase Order for [.firstname.] [.lastname.]</li>
<li><strong>&noemail</strong> (Optional)<br/>Prevents eform from sending emails e.g. no-reply@mydomain.com
Set to 1 to disable emails. Defaults to 0</li>
<li><strong>&mailselector</strong> (Optional)<br/>Sets the name of the form field to use as a selector to select a single email from the comma (,) delimited emails assigned
the
<code>&to</code>parameter. 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.<br/><br/>For example:
<code>&to =`sales@me.com,support@me.com,billing@me.com`
<code>&mailselector</code>=`topic`</code><br/><br/>On the web form the topic fields is actually a dropdown menu. when the user selects a topic from the list the value 1,2 or 3 will
be sent to eForm which will then be used to select one of the three emails assigned to the
<code>&to</code>parameter. This email address will be the address used to send the email to.</li>
<li><strong>&mobile</strong> (Optional)<br/>Mobile email address. This email is used to send a short notification message to a mobile device.</li>
<li><strong>&mobiletext</strong> (Optional)<br/>Text message to send to mobile device Can include [.form fields.]. E.g. Order for
<code>[.firstname.]</code></li>
<li><strong>&thankyou</strong> (Optional)<br/>chunk name (non-numeric) or document id (numeric) to use as a thank you message displayed to the user after a successful submit.
Tags: same as for
<code>&tpl</code></li>
<li><strong>&gotoid</strong> (Optional)<br/>document id to load after sending message. See also
<code>&thankyou</code></li>
<li><strong>&category</strong> (Optional)<br/>Category ID or name used to categorize eForms.
If category is not found a new category will beb created
This will appear in the subject of the email sent to the user</li>
<li><strong>&keywords</strong> (Optional)<br/>Comma delimited keywords or [+formfields+] used when searching databank
E.g. [+firstname+], [+lastname+], [+email+]</li>
<li><strong>&autosender</strong> (Optional)<br/>email to display as sender of the auto-respond message
e.g. no-reply@mydomain.com</li>
<li><strong>"autoSenderName</strong> <span class="new">(new in 1.4.4)</span> (optional)<br />Name to display as sender of the auto-respond message.</li>
<li><strong>&automessage</strong> (Optional)<br/>chunk name (non-numeric) or document id (numeric) to use as an auto-responder message
Can include [+form fields+]. E.g. [+firstname+]
- tags: [form_fields],[postdate]
- note: eForm will send the auto-respond message to the email address specified
inside the [email] form field.</li>
<li><strong>&allowhtml</strong> (Optional)<br/>Set to 1 to allow user to enter html tags. Defaults to 0</li>
<li><strong>&language</strong> (Optional)<br/>Support for multilingual validation and error messages. Uses same language
names as MODx.</li>
<li><strong>&vericode</strong> (Optional)<br/>Enables verification code. The template contain a vericode
field and a [+vericode+] placeholder</li>
<li><strong>&debug</strong> (Optional)<br/>Set to 1 for extended error messages in form validation. Mostly for debugging
#LIST and #SELECT validation.</li>
<li><strong>&sendAsHtml</strong> (optional)<br/>Force email messages to be in Html.
Possible values: &sendAsHTML=`1`- send all messages as html, &sendAsHTML=`report,autotext,mobile`- send specified messages as html</li>
<li><strong>&sendAsText</strong> (optional)<br/>Force email message to be in plain text.
Possible values: &sendAsText=`1`- send all messages as text only, &sendAsText=`report,autotext,mobile`- send specified messages as text only</li>
<li><strong>&sessionVars</strong> (optional)<br/>Comma delimited list of $_SESSION variable names. These will be added to the list of field values before the form is displayed and can for instance be used to populate (hidden) fields.
When using this parameter make sure you are not disclosing sensitive information from the session!! (a hidden field is not all that hidden afterall)<br/>As eForm does not parse the complete form 1st time around you will have to have the same placeholders in the form template so the form can receive the values. So for example:
<code>[!eForm &sessionVars=`jobID` ... !]</code>and
<code><input type="hidden" value="[+jobID+]" /></code></li>
<li><strong>&postOverides</strong> (optional)<br/>Used in combination of
<code>&sessionVars</code>. Normally session variables will overide posted values. By setting &postOverides=`1` posted values will take precedence.</li>
<li><strong>&reportAbuse</strong> (optional)<br/>Setting &reportAbuse=`1` will send an email to the system specified email address if email injection attempts are noticed by eForm. (Use sparingly...)</li>
<li><a name="142new" id="142new"></a><strong>&cssStyle</strong> (optional)<br />
Adds a style declaration to the <head> section of the page when either the form is displayed or the thank you page is displayed (only if the <code>&thankyou</code> parameter is set). Values can be a document id (numeric), chunk name or (relative or absolute) url to css file. Multiple values can be separated by a comma (in fact all three values can be mixed).<br />examples:<br /><code>[!eForm &cssStyle=`assets/site/forms.css,chunkName` ... !]</code><br />
<code>[!eForm &cssStyle=`chunkName` ... !]</code><br />
<code>[!eForm &cssStyle=`http://mysite.com/assets/styles/forms.css` ... !]</code><br />
Chunks (and documents if a doc id is given) can return a values in the form of:
<ol>
<li>an inline style block, eg. <code><style type="text/css">/*some styles*/</style></code></li>
<li>a link to stylesheet(s), eg. <code><link href="assets/site/forms.css" rel="stylesheet" type="text/css"></code></li>
<li>a comma separated list of urls, eg. <code>assets/site/forms.css,assets/site/more.css,assets/site/gone_overboard.css</code></li>
</ol>
</li>
<li><strong>&jScript</strong> (optional)<br />Similar to <code>&cssStyle</code> but for adding javascript to the <head> of the page document. Currently Javascript is only added when the form is displayed. </li>
<li><strong>&protectSubmit</strong>(optional) defaults to 1 (on)<br />
Protects against submitting a form multiple times with the same data. Submitting the form becomes disabled after the first successful submit while the value from key form fields remains the same. This is achieved by setting (and comparing) a session variable with an md5 hash from these key fields. Which fields are compared depends on the value of <code>&protectSubmit</code>.Possible values are <strong>0</strong> (off), <strong>1</strong> (all 'required' fields are used) or you can set a comma separated list of field names. To ensure that the session variable works separatedly for different forms the session variable name is based on <code>&formid</code> ({formid}_hash).
</li>
<li><strong>&submitLimit</strong> (optional) off (0) by default<br />
Enforces a time limit (in minutes) between form submits. After the form has been submitted successfully it can not be submitted again for <code>&submitLimit</code> minutes irrespective of the form data. When used in combination with <code>&protectSubmit</code> <code>submitLimit</code> takes precedence, meaning that when the time limit has expired the form can be submitted again regardless of the setting of <code>&protectSubmit</code> (it will unset the session variable). As with <code>&protectSubmit</code> this parameter uses a session variable with a variable name based on &formid.
</li>
<li><a name="classparams"></a><strong>&requiredClass</strong> (optional)<br />
Css class name. Will add class in (empty) required form fields on validation. Existing classes will be preserved.<br />
<em>If you have already set a class for a field or label and you get unexpected css results check the order in which you have declared the classes. The <code>&requiredClass</code> is added to the beginning of any classes already set.</em>
</li>
<li><strong>&invalidClass</strong> (optional)<br />
Css class name. Will add class in invalid form fields on validation. Existing classes will be preserved.
</li>
<li><strong>&runSnippet</strong> <span class="new">(new in 1.4.4)</span> (optional)<br />
Expects a snippet name. Snippet will be run before any eForm handling. One parameter, the &&formid will be passed to the snippet. Any return value from the snippet is discarded. This can be used to insert functions as an alternative to declaring a separate snippet in the document. Sadly eForm will silently ignore a snippet that does not exist due to the way $modx->runSnippet handles snippet return values.
</li>
<li><strong>&snipFolder</strong> <span class="new">(new in 1.4.4)</span> (optional)<br />
For those that want to keep different versions of eForm active. You can now save all of eForm's files in a different directory and set the &snipFolder accordingly. You can for instance save version 1.4.4 in the 'assets/snippets/eform/1.4.4' folder and set <code>&snipFolder=`eform/1.4.4`</code>. The value of &snipFolder is added to the basic snippets folder 'assets/snippets/'.It should not include a closing slash (/)!</li>
</ul>
<a name="events"></a>
<h4>PHP Event Functions:</h4>
<p>The eForm event functions are now incorporated into the parameters. They are:</p>
<ul class="qe_param_list">
<li><strong>&eFormOnBeforeMailSent</strong> (optional)<br/>Expects a function name. This function will be called after the form has been validated and before the report and thankyou templates have been parsed and any emails have been sent out.
See <a href="eform_example_events.htm">this example</a> on how to use the events.</li>
<li><strong>&eFormOnMailSent</strong> (optional)<br/>Expects a function name. This function is called after all templates have been parsed and any emails were sent.</li>
<li><strong>&eformOnBeforeFormParse</strong> (optional)<br/>
Expects a function name. The function is called after the templates are loaded and the formid is found valid. The function should accomodate the following parameter: &$templates - (as reference) an associative array of loaded templates with indexes 'tpl', 'report','thankyou' & 'autotext'. Be aware that the latter three will only have a value if the form has been posted!
</li>
<li><strong>&eFormOnBeforeFormMerge</strong> (optional)<br/>Expects a function name. This function will <strong>only</strong> be
called whenever the form is displayed and just before all placeholders
are merged. The function should accomodate the following parameter: &$fields
- (as reference) an associative array of field and placeholder values.</li>
<li><strong>&eFormOnValidate</strong> (optional)<br/>Expects a function name. This function will be called directly after
the form validation has taken place. You can use this event to add
your own extra validation logic. The function should accomodate the
following parameters
<ul>
<li>&$fields - (as reference) an associative array of field and placeholder
values.</li>
<li>&$vMsg - (as reference) a numeric array of validation error messages.</li>
<li>&$rMsg - (as Reference) a numeric array of missing required
fields.</li>
</ul></li>
</ul><h3>Examples:</h3>
<p>
<code>[!eForm?
&to=`me@mydomain.com`
&gotoid=`1`
&tpl=`orders`
&report=`orderreport`
!]</code><br/>
<code>[!eForm?
&to=`sales@mysuppliers.com`
&category=`Purchase Order`
&tpl=`chunkPurchaseOrder`
&report=`chunkPurchaseReport`
!]</code></p>
</div>
<a name="placeholders" id="placeholders"></a>
<h2>Placeholders</h2>
<div class="qe_level_2">
<p>For all normal form fields eForm automatically inserts appropriate placeholders. However there are a few that you may need to add manually:</p>
<ul class="qe_param_list">
<li><code>[+validationmessage+]</code> - This should be somewhere in your form template or document. It is used for any validation error messages. From 1.4.2 the way the placehloder is entered has changed. Firstly you no longer need to place it in the form template. You can now place it anywhere in your document (or even in the global page template). Secondly you don't need to place any hml tags around the placeholder (in fact you probably should not). Any html markup is now included in the <code>$_lang['ef_validation_message']</code> variable in the eform language files (which you can change as required).</li>
<li><code>[+vericode+]</code> & <code>[+verimageurl+]</code> - These are needed in the form if you want to use the CAPTHCA code. See the <a href="eform_examples.htm">Examples</a> on how to use these.</li>
<li><code>[+postdate+]</code> - 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)</li>
<li><code>[+debug+]</code> - 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.</li>
</ul>
</div>
<a name="datatypes" id="datatypes"></a>
<h2>Datatypes and formatting</h2>
<div class="qe_level_1">
<p>eForm is incorporating a form parser which extracts formatting and validation options from each form field. To set options for a field add the <code>eform</code> (pseudo) attribute to each required form field.</p>
<p>
<code><input type="text" name="color" eform="A Color:string:1" /></code></p>
<p>The basic format of the eform attribute is:<br/><br/>
<code>[description/title]:[datatype]:[required]:[validation message]:[validation rule]</code></p>
<div class="qe_level_2"><h3>Data types</h3>
<p>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)</p>
<p>Standard validation: All fields that are required will be checked if they are left empty.</p>
<ul class="qe_param_list">
<li><strong>string</strong> - No specific validation besides checking if it's empty if the field is required.</li>
<li><strong>date</strong> - Checks if it is a valid date (based on php's strtotime() function)</li>
<li><strong>integer</strong> - Checks if it is a number (does not check if it is in fact an integer)</li>
<li><strong>float</strong> - Checks if it is a number</li>
<li><strong>email</strong> - Checks if it's a valid email address using a simple regular expression</li>
<li><strong>file</strong> - (for file upload input) - checks if a size error occurs, does not currently check file type</li>
<li><strong>html</strong> - Same as string except that it converts line endings (\n) to <br /> tags</li>
</ul>
<p>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.</p>
</div>
</div><a name="validation" id="validation"></a>
<div class="qe_level_1"><h2>Extended Server Validation</h2>
<p>This version instroduces extended server validation and word filtering using very flexible validation rules that can be set in the <code>eform</code> attribute. You can set 2 extra validation parameters, a custom error message and a validation or filter rule.</p>
<p>example:
<code>eform="Year of Birth:integer:1:Must be between 1950 and 2002:#RANGE 1950-2002"</code></p>
<div class="qe_level_2"><h3>The validation rules</h3>
<ul class="qe_param_list">
<li><strong>#LIST</strong> - comma separated list of valid values<br/>example:
<code>#LIST blue,red,green.maroon</code></li>
<li><strong>#RANGE</strong> - a comma separated list of numbers or numeric ranges.
When setting a range the order is not important. 1~10 or 10~1 will both validate a number
between 1 and 10 (inclusive). Handles negative as well as positive numbers<br/>example:
<code>#RANGE 1,3,-5~-15,60~82</code></li>
<li><strong>#SELECT</strong> - list of valid values retrieved from a database query
The query should only return a single column of values (the function only checks
against the first returned column). You can use the
<code>{DBASE}</code>
<code>{PREFIX}</code>tags which will be replaced by the MODx database name and table prefix respectively.<br/>example:
<code>#SELECT keyword FROM {PREFIX}site_keywords</code></li>
<li><strong>#EVAL</strong> - string of php code. Should return either true or false<br/><span style="color:#c00">deprecated</span>Although #EVAL still works in eForm 1.4 this rule will very likely no longer be supported in future versions. Use #FUNCTION instead.<br/></li>
<li><strong>#FUNCTION</strong> - Name of a function. The function should expect one parameter (the posted value) and return either TRUE or FALSE.
See the <a href="eform_example_events.htm">eform event example</a> on how you can include a function.
example:
<code>#FUNCTION myValidationFunction</code></li>
<li><strong>#REGEX</strong> - regular expression - syntax as for preg_match() - see php manual<br/>example:
<code>#REGEX /^[a-z]+ [a-z0-9_]+/i</code></li>
<li><strong>#FILTER</strong> - Filters do not validate the input but
simply replace words or values using filter criteria. You can use the following filters:
<ul>
<li>#FILTER #LIST<br/>use double pipe to separate 2 comma separated lists of words and
replacement values.<br/>example;
<code>#FILTER #LIST badword,verybadword||goodword,verygoodword</code></li>
<li>#FILTER #EVAL<br/>example:
<code>#FILTER #EVAL return myFilterFunction($value);</code><br/>(offcourse you have to make sure the function exists somehow)<br/><br/><em>example filter function</em><br/>
<code>function myFilterFunction($value){<br/> $badWords = array('scribble','coding');<br/> $goodWords = array('design','sleep');<br/> return str_replace($badWords,$goodWords,$value);<br/>}</code></li>
<li>#FILTER #REGEX<br/>regular expression replace - syntax as for preg_replace()
separate the search and replacement expression with a double pipe symbol (||)<br/>TODO: example</li>
</ul></li>
</ul><h3>Select boxes, radio options and checkbox fields</h3>
<p>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</p><h3>Hidden fields</h3>
<p>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).</p>
<p>Hidden field example 1.<br/>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:<br/>
<code><input type="hidden" name="docId" value="31" /></code></p>
<p>Hidden field example 2.<br/>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:
<code><input type="hidden" name="calculatedField" value="" eform="::0::" /></code></p>
<p>Hidden field example 3.<br/>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)
<code><input type="hidden" name="calculatedField" value="" eform="Calculated Value:integer:1:Calculation out of range:#RANGE 1-10" /></code></p><h3>Form field examples with validation</h3>
<p>1. Selectbox - set as required field (no validation required)</p>
<div class="codeblock"> <select name="mySelect" eform_options="Select Country::1" /> (datatype left blank)<br/><option value="en-au">Australia</option><br/><option value="en-us">USA</option><br/></select>
</div>
<p>2. Textbox - required and format set to date</p>
<div class="codeblock"> <input type="text" name="dobDate" eform_options="Date of Birth:date:1:@EVAL return (strtotime($value)!==-1)?true:false;" />
</div>
<p>3. Multiple checkbox - required, eform_options only set once.</p>
<div class="codeblock"> <input type="checkbox" name="myColors[]" value="Red" eform_options="Colors::1" /> (datatype left blank)<br/><input type="checkbox" name="myColors[]" value="Green" /> (datatype left blank)<br/>
</div>
</div><h2>Todo</h2>
<ul>
<li>Custom css classes for invalid fields (add to or create class attributes)</li>
</ul>
</div>
</div>
</body>
</html>