Description
This module can be used to collect user input via a web form and receive the filled form via email.
This module is NOT publicly available. Please contact moc.todikiw|troppus#moc.todikiw|troppus for more details.
Attributes
| attribute | required | allowed values | default | description |
|---|---|---|---|---|
| yes | a valid email address | none | this is an email the filled forms will be sent to | |
| format | no | "csv" | none | chooses alternative format of serializing the form data |
| title | no | text | "Wikidot.com - MailForm form data" | title of the email containing the submitted form |
| successPage | no | valid page name | none | after the form is sent the browser will be redirected to the specified page. put a "thank you" there if you wish ;-) |
The definition of the form must be enclosed within the [[module … ]] … [[/module]] tags. The full specification of how to do this:
The definition of the fields is a nested list that looks like this:
# field1_name
* option1_name: value
* option2_name: value2
* suboption1_nam: value
# field2_name
* ...
where field_name is the alphanumeric identifier of the field, e.g. first_name. The options are:
| option name | required | allowed values | default | description |
|---|---|---|---|---|
| title | no, but recommended! | any string | field_name | title of the field displayed in the same row on the left |
| type | no | text, checkbox, select, checkbox | text | type of the input field |
| size | no | integer | 30 | size of the input field |
| default | no | value of the input | none | in case of the "text" or "textarea" fields it is just a string that appears inside the field; in case of "select" it must be one of the option labels |
| hint | no | any text | none | |
| options | only for "select", see below | |||
| rules | validation rules, see below | |||
"Select" type
If your field is a "select" field, you must also provide options for it. Do so as shown:
# field_name
* title: Gender
* type: select
* default: male
* options:
* male: Male
* female: Female
* option_name: Displayed value
where the "default: …" is not required, but if provided it should match one of the names of the options.
Validation
This module offers a powerfull way to validate the input data. To use validation do:
# field_name
* title: Validated field
* type: text
* rules:
* rule1_name: value
* rule2_name: value
where rules are:
| rule name | allowed values | description |
|---|---|---|
| required | anything, e.g. "true" | if the field is required |
| minLength | integer | does not allow strings shorter than limit |
| maxLength | integer | does not allow strings longer than limit |
| match | perl regular expression | checks the value against expression, e.g. /[a-z0-9]+/ allows only lowercase letters and numbers |
| number | anything, e.g. "true" | checks if numeric |
| minValue | number | for numerical fields sets the lower limit |
| minValue | number | for numerical fields sets the upper limit |
Examples
Ok, suppose you are making some kind of conference registration and want to grab participants' data:
[[module MailForm email="trash@wikidot.com"]]
# name
* title: Your name
* type: text
* rules:
* required: true
# affiliation
* title: Institute/Organization/Company
* hint: leave blank in none
# address
* title: Address
* rules:
* required: true
* minLength: 2
# address2
* title: Address (cont.)
# country
* title: Country
* rules:
* minLength: 2
# phone
* title: Phone
# email
* title: Email
* type: text
* rules:
* match: /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/
# payment
* title: I will pay by
* type: select
* options:
* creditcard: Credit card
* banktransfer: Bank wire transfer
* desk: At the registration desk
* na: Not applicable
# logging
* title: Please find me a hotel
* type: checkbox
* hint: we will contact you via email if yes
# comments
* type: textarea
* title: Extra comments
* rules:
* maxLength: 500
[[/module]]