Install the module with the Extension manager.
Insert a “plugin” element on the page where the form should be shown – pluginname: “mailformplus”.
Insert a new “mailformplus” element on the page: (make sure you only have one mailformplus element per page!) best practice: switch to “list” view and click on “create new record” on the very bottom of the page.
configure the mailformplus element Tipp: since version 3.5.0 you can define default values for the fields via TypoScript! see section “General TypoScript” for more information.
error handling: if you need specific/advanced server side error handling, you can define the error check(s) of the fields via TypoScript. (since 3.9)
If you are using file uploads within your form, the user or admin receives an email having showing a link to the uploaded file(s). After the update to 3.9.0 only the filename will be shown. To fix this, you have to define the correct TS settings for the field:
plugin.tx_thmailformplus_pi1.fieldConf.[name of fileupload field] {fileUpload = uploads/pics/
uploadedFiles.mail {plainTemplate = ###filePath######fileName###\n
}
}
If you are using the new functionality to send HTML-mails, you should also define:
uploadedFiles.mail.HTMLTemplate = <a href="###filePath######fileName###">###fileName###</a><br>
This is a “normal” static HTML document including the formular fields.
Make sure you don't have a <BODY> or <HTML> tag in there – it should only contsists of the real pure HTML-form starting with <form .... > and ending with </form>
You can also declare javascript functions if you like to check some fields before the form is submitted.
Example forms:
In the /th_mailformplus/example_form/ directory you find two example templates files and one example TypoScript file.
mailformplus_demo.html:
a singlepage form example
multipage.html:
a multipage form example with file upload, error checks,...
multipage_TypoScript_setup.txt
example TypoScript settings for the “multipage.html” example
Guidelines for the HTML-template:
make sure that:
each form has a form-start-tag beginning with "<form" or "<FORM"
each multipage-form has a form-end-tag "</form>" or "</FORM>"
fieldnames are enclosed by " eg. <input type="text" name="email">
Requirements for multipage forms:
only woks with JavaScript enabled
add the marker ###ADDITIONAL_MULTIPAGE### in every step between the <form> and </form> tag.
This is where the automatic generated JS function and hidden fields are written.
Hidden fields you have to declare in the HTML-form:
<input type="hidden" name="id" value="###PID###">
<input type="hidden" name="submitted" value="1">
<input type="hidden" name="L" value="0">
Subtemplates:
###TEMPLATE_FORM### | Main form template including <form></form> tag. Use this Subtemplate for a singlepage form. |
|---|---|
###TEMPLATE_FORM[1...x]### | Main form template including <form></form> tag. Use this Subtemplate for a multipage form. example: ###TEMPLATE_FORM1### begin/end ... step 1 ###TEMPLATE_FORM2### begin/end ... step 2 Subtemplates: To be defined in first step (###TEMPLATE_FORM1###). ###FORM_STARTBLOCK### begin/end ###FORM_ENDBLOCK### begin/end can be used as markers in the following steps: ###STARTBLOCK### ###ENDBLOCK### example: Step 1: <!-- ###TEMPLATE_FORM1### begin --> <!-- ###FORM_STARTBLOCK### begin--> ... <!-- ###FORM_STARTBLOCK### end--> ... ... ... <!-- ###FORM_ENDBLOCK### begin --> ... <!-- ###FORM_ENDBLOCK### end --> <!-- ###TEMPLATE_FORM1### end --> Step 2: <!-- ###TEMPLATE_FORM2### begin --> ###STARTBLOCK### ... ... ###ENDBLOCK### <!-- ###TEMPLATE_FORM2### end --> |
###TEMPLATE_SUBMITTED_OK### | This subtemplste is shown if form was submitted and all required fields were filled out and no redirect is defined. |
###TEMPLATE_EMAIL_USER### ###TEMPLATE_EMAIL_USER_HTML### | Plaintext/HTML text sent to the user. (only if this function is used) Define both subparts (plain and HTML) because since version 3.9.0 all mails are sent as multipart mails . Means: if the users email client is not able to display HTML mails, the plaintext mail is shown – otherwise the HTML mail. |
###TEMPLATE_EMAIL_RECEIVER### ###TEMPLATE_EMAIL_RECEIVER_HTML### | Plaintext/HTML text sent to the receiver specified in the mailformplus record or via TypoScript. also see ###TEMPLATE_EMAIL_USER### |
###TEMPLATE_PRINT### | HTML template which will be stored in session after the form got submitted. With the help of a user-function you can display this template (with replaced markers of course) on the “thank you” page. Use ###value_[name of inputfield]### or ###[name of inputfield]### markers as in all other sutemplates. Also see section “print template” for more informations. |
###TEMPLATE_ERROR### | Define error messages for each input field within this subpart. example: <!-- ###TEMPLATE_ERROR### begin --> <!-- ###ERROR_email### begin --> Fill out a correct email address! <!-- ###ERROR_email### end --> <!-- ###TEMPLATE_ERROR### end --> |
Markers:
###value_[name of inputfield]### | GET/POST value of the given inputfield. example: <input type=”text” name=”email” value=”###value_email###”> |
|---|---|
###checked_[name of inputfield]_[value of inputfield]### | Only for use with checkboxes and radiobuttons. example: checkbox: <input type="checkbox" name="topic" value="webdesign" ###selected_topic_webdesign###>Webdesign radiobutton: <input type="radio" name="contact_via" value="email" style="border-style:none;" ###checked_contact_via_email###>e-mail |
###selected_[name of dropdown]_[value of dropdown]### | Only for use with dropdowns. example: dropdown:: <option value="webdesign" ###selected_topic_webdesign###>Webdesign</option> |
###[marker name from TypoScript]### | Marker defined in TypoScript. example: plugin.tx_thmailformplus_pi1.markers.departments < temp.departments |
###ERROR### | Cumulated error messages. |
###error_[fieldname]### | Error text for one specific field. Error-text can be defined via subtemplate (see above section) or via TypoScript. |
###FEUSER_[fieldname]### | You can access name, email, ... fields from the logged in user (frontend-user) and fill out the name or emailaddress automatically. Attention: the fieldname has to be written in CAPITAL letters. |
###CAPTCHA### | Only works if you have the “captcha” extension installed. This marker will be replaced with a picture showing some only human readable text. The user has to type the text shown on the picture into a inputfield in your form. To enable the check if the submitted text is the same as shown on the picture, you have to set the following TypoScript: plugin.tx_thmailformplus_pi1.captchaFieldname = [name of the inputfield] See section “general Typoscript” for more information. |
Specific markers for multipage forms: | |
###ADDITIONAL_MULTIPAGE### | This marker has to be inserted in every step-subtemplate within <form> and </form> tag. This is where the automatic generated JS function and hidden fields are written. |
###curStep### | Number of current step. |
###maxStep### | Number of steps. |
###link_nextStep_start### ###link_nextStep_stop### | <a> start-tag for next page </a> end-tag for next page |
###link_prevStep_start### ###link_prevStep_stop### | <a> start-tag for previous page </a> end-tag for previous page |
###link_reload_start### ###link_reload_stop### | <a> start-tag for submitting form but stay on the same step </a> end-tag for submitting form but stay on the same step |
Specific markers for file uploads: | |
###[name of upload field]_fileTypes### | Allowed filetypes defined in TS eg. “jpg,gif,pdf” |
###[name of upload field]_fileSize### | Maximum allowed filesize per file defined in TS. |
###[name of upload field]_numberOfAllowedFiles### | Maximum number of files that can be uplaoded with this field. |
###[name of upload field]_numberOfUploadedFiles### | Number of uploaded files via this field. |
###[name of upload field]_numberOfRemainingFiles### | Number of remaining files that can be uploaded |
plugin.tx_thmailformplus_pi1
emailHeader * | optional to send out HTML-emails or emails with UTF-8 encoding the values will be added to the header of all emails that are sent out comment: if you don't specifiy your own charset here, the default character set of the typo3 installation is taken |
emailParameter * | optional this string is used when sending the mail via the php mail() function as 5th parameter example: emailParameter = -f automailer@yourdomain.com |
markers | optional syntax: markers.[markername] = [TypoScript] [markername] has to be used within the HTML-template as marker: ###[markername]### see example below |
captchaFieldname | optional Only works if you have the extension “captcha” installed. Set the name of the inputfield where the user types in the text shown on the captcha-picture. example: captchaFieldname = captcha_check |
saveUserFunc | optional Calls an user defined function after the form was submitted successfully. example: saveUserFunc = EXT:myext/class.tx_myext.php:tx_myext->doit Parameters can be passed on to the user function like this: saveUserFunc.dummy = hello See section “Hook for post-processing” for more details. |
limitMailsToUser | Limit the number of mails that are sent to the user. default value (if not defined in TS): 2 Only necessary if you are sending a confirmation mail to the users email address he/she filled out. (multiple email addresses could be filled which opens the doors for spamming) |
* .. no longer used since version 3.9.0
plugin.tx_thmailformplus_pi1.default
The default settings specified via TypoScript are used if the corresponding field in the mailformplus record is not filled out. Since version 3.9.0 you can not only set sting values, but also TypoScript “TEXT” objects to all the listed .default settings. example: plugin.tx_thmailformplus_pi1.default.email_subject = TEXT plugin.tx_thmailformplus_pi1.default.email_subject.data = GPvar:subject plugin.tx_thmailformplus_pi1.default.email_subject.wrap = 1|2 | |
.email_to | help@mydomain.com Info: That's the email address where the “admin” email is sent to. |
.email_subject | [text] contact form was filled out Info: That's the subject of the admin-email. |
.email_sender | [email] Info: This emailaddress is used as sender in the admin-email. |
.email_redirect | [pageID] 10 Info: PageID where the user gets redirected to when submitting a correct filled out form. |
.email_requiredfields | [fieldnames] used in the form name,email Info: Use fieldnames of the inputfields to enable a server side check if they are filled out. |
.email_requiredfields.wrap | to add required fields dynamicly example: email_requiredfields.wrap = |,subject |
.email_htmltemplate | [path] to html-template ../../fileadmin/forms/contact.html ATTENTION: always use “../../” as prefix! Info: This is the path and the HTML-template file with the form. |
.email_replyto | [fieldname] used in the form Info: Fill in the name of the formular inputfield where the user fills in the email address. This emailaddress is then taken as reply-to address. Clicking on “reply” in your email program to an admin-email lets you send an email directly to the user. |
.email_sendtouser | [fieldname] used in the form user_email Info: If you want a email to be sent to the user who has submitted the form, you have to use the inputfield name where the user puts in his/her emailaddress here. |
.email_subject_user | [text] Thank you for your registration. Info: That's the subject of the email sent to the user. (see “email_sendtouser”) |
plugin.tx_thmailformplus_pi1.fieldConf.[name of inputfield]
Since 3.9.0 more detailed settings per input field can be defined. - error checks (server side) - default value (TS TEXT object) - upload field settings eg. allowed fileTypes, fileSize,... | |
.defaultValue | TypoScript “Text” object definition. example: fieldConf.email.defaultValue.value = admin@mydomain.at .defaultValues {day.data = date :U day.strftime = %d month.data = date : U month.strftime = %b year.data = date : U year.strftime = %Y } |
.errorCheck | Server side error check for the field. This TS setting overrules the “required” setting in the mailformplus record! .errorCheck can be one of the following: - email ..... validated as email - integer ... validated as integer - float .... validated as float ("." and "," allowed!) - required ... must be filled out - optional ... field is optional, but if it's filled out, it's validated to the rest of errorChecks defined - date ... validated as date. format can/has to be specified example: errorCheck = date:dd/mm/yyyy errorCheck = date:d.m.y format is case insensitive. dd/mm/yyyy equals DD/MM/YYYY - time ... validated as time. format can/has to be specified example: errorCheck = time:hh:mm errorCheck = time:h-m format is case insensitive. hh:mm equals HH:MM - ereg ... validated to match the regexp given example for correct IP validation: errorCheck = ereg:^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$- eregi ... like "ereg" but case insensitive You can specify multiple errorchecks by separating them by "," example: .errorCheck = required, email |
.errorText | Text beeing displayed when error occurs. Info: .errorText overwrites the error-subtemplate value defined in the template. example: email.errorText = <li>fill out a correct email</li><br> |
Settings only for file upload fields: Uploaded files are saved as [md5 hash]_[page-id]_[saveDB id if exists]_[original filename] | |
.numberOfAllowedFiles | Number of files the user is allowed to upload via this upload field. How can a user upload multiple files? Have a look at the example template in /th_mailformplus/example_form/ |
.fileTypes | Allowed file types. example: picture.fileTypes = jpg,gif |
.fileSize | Maximum file size for one uploaded file in Bytes. example: picture.fileSize = 200000 |
.fileUpload | Directory where uploaded files are stored. example: picture.fileUpload = uploads/pics/ |
Special templates and wraps for fileuploads which are used for - the webpage (generally for all steps - if it's a multipage form ) - the webpage (for one specific step – if it's a multipage form) - the mails (to receiver and user – for HTML and for plaintext mails separate templates/wraps) - the mail to the receiver (for HTML and plaintext mails separate templates/wraps) - the mail to the user (for HTML and plaintext mails separate templates/wraps) | |
.uploadedFiles.template | Template taken for each uploaded file and can be used as ###value_name of inputfield]### marker in the HTML output on the webpage. Markers to be used within the template: - ###fileName### - ###fileSize### ... file size formatted by t3lib_div::formatSize() function - ###linkDelete_start### - ###linkDelete_stop### example: picture.uploadedFiles.template = <tr><td>###fileName###</td><td>###linkDelete_start###remove file###linkDelete_stop###</td></tr> |
.uploadedFiles.wrap | Wrap around the lines for each uploaded file (see above). example: picture.uploadedFiles.wrap = <table border="0" cellspacing="0" cellpadding="0">|</table> |
.uploadedFiles.[step].template | Overwrites the default uploadedFiles.template setting for one specific step. This setting of course only makes sense if you are using multipage forms. |
.uploadedFiles.[step].wrap | Overwrites the default uploadedFiles.wrap setting for one specific step. |
.uploadedFiles.print.template .uploadedFiles.print.wrap | Template taken for each uploaded file and can be used as ###value_[name of inputfield]### marker in the print template. example: uploadedFiles.print.template = <a href=”###filePath######fileName###”>###fileName###</a><br> uploadedFiles.print.wrap = uploaded files:<br>|end of uploaded files<br> Also see examples-section for more information about the print template. |
.uploadedFiles.mail.plainTemplate .uploadedFiles.mail.HTMLTemplate .uploadedFiles.mail.plainWrap .uploadedFiles.mail.HTMLWrap | Template taken for each uploaded file and can be used as ###value_[name of inputfield]### marker in the mails to receiver and user. example: uploadedFiles.mail.plainTemplate = ###filePath######fileName###\n uploadedFiles.mail.HTMLTemplate = ###filePath######fileName###<br> uploadedFiles.mail.plainWrap = uploaded files:\n|\nend of uploaded files\n uploadedFiles.mail.HTMLWrap = uploaded files:<br>|<br>end of uploaded files<br> |
.uploadedFiles.mailReceiver.plainTemplate .uploadedFiles.mailReceiver.HTMLTemplate .uploadedFiles.mailReceiver.plainWrap .uploadedFiles.mailReceiver.HTMLWrap | Template taken for each uploaded file and can be used as ###value_[name of inputfield]### marker in the mails to receiver. (overwrites the .mail.plainTemplate and .mailHTMLTemplate templates) If no HTMLTemplate is defined, but HTML mails are sent, the template of plainTemplate is taken instead. example see above |
.uploadedFiles.mailUser.plainTemplate .uploadedFiles.mailUser.HTMLTemplate .uploadedFiles.mailUser.plainWrap .uploadedFiles.mailUser.HTMLWrap | Template taken for each uploaded file and can be used as ###value_[name of inputfield]### marker in the mails to user. (overwrites the .mail.plainTemplate and .mailHTMLTemplate templates) If no HTMLTemplate is defined, but HTML mails are sent, the template of plainTemplate is taken instead. example see above |
plugin.tx_thmailformplus_pi1.multiPage
.js | JavaScript function call before form is submitted. example: .js = alert('general javascript'); |
|---|---|
.[step].js | JavaScript function for one specific step – called before form is submitted. example: .1.js = alert('step1 javascript'); |
(since 3.1)
This allows you to choose a database table and store all (or some) values submitted via a formular into this table.
Also fileuploads can be handled.
Typoscript support:
plugin.tx_thmailformplus_pi1
saveDB = 1 | 1 ... enable saving to DB 0 ... disable saving to DB (or if not defined) |
saveDB.dbTable | Name of database table used for saving |
saveDB.fileUpload * | optional Directory where the uploaded files (if any) are stored. The file will be renamed to: [pageID]_[FormularInputFieldName]_[createdRecordID].[fileType] Example: saveDB.fileUpload = uploads/tx_threzepte/ |
saveDB.fileTypes * | optional allows only uploaded files of this type. Seperate mulitple types by “,” data will not be saved if the file does not correlate with this types. (use ###error_filetype### placeholder for displaying the error message) Example: jpg,gif,png,jpeg |
saveDB.fileSize * | optional this limits the maximum size of one uploaded file – data will not be saved if the file is too large (use ###error_filesize### placeholder for displaying the errormessage) Example: 50000 (50 Kb) |
saveDB.dbinsert | optional inserts given values into the databse. Useful if you want to set the inserted records to “hidden” example: pid:7,hidden:1 |
saveDB.dbkey | Default: uid If you want to insert the records into a table that does not use “uid” as key field. Important because the generated key is taken as part of the filename (if you allow the user to upload a file with the form) |
saveDB.mapping | Not default! You have to specify into which table field the form field is saved. Abstract: [inputFieldName]:[DBName],[inputFieldName]:[DBName],... Example: surname:name,title:title,ingredients:ingredients Howto write two submitted values in one DB-field: Simply write the two mappings separated by “,”. example: surname:name,forename:name |
saveDB.debug | ATTENTION: If the extension does not work as expected, set this to 1 to display various debug messages. Do NOT activate this feature on an online page – the messages would be displayed also to the users! |
saveDB.if_is_empty.[fieldname] | optional [fieldname] ... name of formular inputfield If field is not filled out, you can specify a default value which will be used. Example: saveDB.if_is_empty.subscribe = no |
* ... file handling settings. These settings are used for each file upload field. In version > 3.8.0 these (and more) settings can be defined per upload field. See plugin.tx_thmailformplus_pi1.fieldConf settings.
(since 3.3)
This allows you to specify which fields have to be saved in the log-table and in which order.
Default: all fields submitted (having a value) are saved.
When you use checkboxes in your form, a unchecked checkbox won't be saved at all in the log-table. This causes incompatibility in the csv-export-format.
Use this typoscript functionality to ensure a fix format for your csv-exports.
plugin.tx_thmailformplus_pi1
saveLog = 1 | 1 ... enable customized saving to log-table 0 ... disable customized saving to log-table (or if not defined) default: 0 (all submitted fields having a value are saved) |
saveLog.order | specify formular inputfield names seperated by “,” that should be saved into log-table Attention: fields in log-table are also written in this order |
saveLog.defaultValue | optional default: '' specify the value that should be saved if the user has not filled out the formular field. e.g.: a checkbox is not checked |
saveLog.exclude | specify formular inputfield names seperated by “,” that should NOT be saved into log-table all other fields are saved (since 3.4.0) |