Example
If you have activated validation JS in constants (default), than you can validate values of textfields just after input in frontend:
Example: Mandatory check
Example: E-Mail check
Check for:
This validation of textfields are currently possible:
Mandatory
URL
Numbers
Numbers (with comma or point)
Letters
Letters and numbers
Error Message:
Note: Current error messages are in german and english – you can change or add your own messages via locallang or typoscript (see above)
Stylesheet classes to manipulate validation messages and input fields:
If error in inputfields: <input class=“validation-failed” />
If no error in inputfields: <input class=“validation-passed” />
DIV Layer of errormessage: <div class=”powermail_mandatory_js”>error</div>
Email of sender
Email of user will be automaticly checked, as soon as the email field is selected in backend
Setting a field to mandatory via typoscript instead of flexform setting
plugin.tx_powermail_pi1 {validate.uid41.required = 1
}
With this possibilitiy you can set fields to required, if another field was not filled (phone field could be mandatory if email field is empty)
[globalVar = GP:tx_powermail_pi1|uid40= ]
[else]
plugin.tx_powermail_pi1.validate.uid66.required = 1
[end]
Autocheck via typoscript
Use typoscript to check any field like (example to check uid41 if it is an email):
plugin.tx_powermail_pi1 {validate.uid41.auto = email
validate.uid41.errormsg = Please check your email, there is an error!
}
This autochecks are possible:
email: check if value is an email
url: check if value is a correct url
numbers: only numbers allowed
phone: numbers and / and + and - allowed
alphanum: only numbers and characters allowed
Manual check via typoscript (using regulare expressions)
Use typoscript (in the setup) to check any field like (example to check uid41 if it is an url):
plugin.tx_powermail_pi1 {validate.uid41.expression = ^(http://)?([a-z0-9-]+\.)+([a-z0-9-]{2,3})$^validate.uid41.errormsg = Sorry, but this is not a correct URL, try again!
}
You can enter any regulare expression go check your field values
Further regex examples:
plugin.tx_powermail_pi1 {validate.uid23.expression = /^alex\@wunschtacho\.de$/
validate.uid23.errormsg = Sorry, but this field should contain alex@wunschtacho.de!
}
plugin.tx_powermail_pi1 {validate.uid25.expression = /^###UID26###$/
validate.uid25.errormsg = Sorry, but your password fields are different – try again!
}
plugin.tx_powermail_pi1 {
# extern db entry (example for tt_adress)
dbEntry {
# enable or disable db entry for tt_address
tt_address._enable = TEXT
tt_address._enable.value = 1
# add mm relation to uid 2 of tt_address_group (via mm table)
tt_address._mm = COA
tt_address._mm.10 = COA
# 1 is always the mm table
tt_address._mm.10.1 = TEXT
tt_address._mm.10.1.value = tt_address_group_mm
# 2 is always the other table
tt_address._mm.10.2 = TEXT
tt_address._mm.10.2.value = tt_address_group
# 3 is always the uid of the other table to get a relation to this (in this case uid2 of tt_address_group)
tt_address._mm.10.3 = TEXT
tt_address._mm.10.3.value = 2
# table "tt_address" with field "email" is a static value => alexander.kellner@einpraegsam.net
tt_address.email = TEXT
tt_address.email.value = alexander.kellner@einpraegsam.net
# table "tt_address" with field "pid" is the current pid (e.g. 12)
tt_address.pid = TEXT
tt_address.pid.field = uid
# table "tt_address" with field "tstamp" is the current time as timestamp (like 123456789)
tt_address.tstamp = TEXT
tt_address.tstamp.data = date:U
# table "tt_address" with field "address" is the current formatted time (like "Date: 20.01.2009")
tt_address.address = TEXT
tt_address.address.data = date:U
tt_address.address.strftime = Date: %d.%m.%Y
# table "tt_address" with field "name" is the value from powermail (tt_content uid 88) field uid18 (###uid18###)
tt_address.name = TEXT
tt_address.name.data = TSFE:fe_user|sesData|powermail_88|uid18
# table "tt_address" with field "last_name" is the value from powermail (tt_content uid 88) field uid18 (###uid18###)
tt_address.last_name = TEXT
tt_address.last_name.data = TSFE:fe_user|sesData|powermail_88|uid18
# table "tt_address" with field "company" is the value from powermail (tt_content uid 88) field uid21_1 (###uid21_1###) (e.g. a checkbox value)
tt_address.company = TEXT
tt_address.company.data = TSFE:fe_user|sesData|powermail_88|uid21|1
}
}
Saving is available only if table and field are existing
Every table contains one record
If you want to use more than only one mm relation, you can use tt_address._mm.10 and tt_address._mm.20 and so on...
With this small add to powermail, you can use powermail for many features like guestbook form, tipafriend form, fe_user registration, tt_address registration and so on...
Is there a fitting piVar like &tx_powermail_pi1[uid11]=text, than use this value, and if not...
Is there a value in the session, so fill field with this value, and if not...
Is there a value set in the backend flexform, take this value, and if not...
Should this field filled with logged in fe_user datas (set in backend), take this value, and if not...
Was typoscript used to prefill a field, use this (see example below), and if not
Don't fill
plugin.tx_powermail_pi1 {
prefill {
# fill field uid997 with a static text
uid997 = TEXT
uid997.value = example value
# fill field uid998 with current timestamp
uid998 = TEXT
uid998.data = date:U
# fill field uid998 with current date like "Date: 20.01.2009"
uid996 = TEXT
uid996.data = date:U
uid996.strftime = Date: %d.%m.%Y
# fill field uid995 with IP address of the user
uid995 = TEXT
uid995.data = getIndpEnv:REMOTE_ADDR
}
}
Maybe it's usefull to fill some hidden fields with hidden but important values (IP address, timestamp, Language, GET params, etc..)
We suggest you to use the extension wt_spamshield for fighting spam entries (see details in manual wt_spamshield)
You can also use captcha (see next paragraph)
First of all install a captcha extension like captcha or sr_freecap
Be sure, that you have chosen this extension via constants (captcha or sr_freecap)
As you can add a normal textfield, you can add a captcha field, thats all
If you have installed captcha AND sr_freecap, the extension use sr_freecap
If you have not installed one of this extensions, an error message in frontend is shown
Add new field (typoscript) and use (e.g.) lib.object in this field
Add your typoscript in the setup field to fill lib.object (see example below)
# Get all tt_address datas from pid=5
lib.object = COA_INT
lib.object {
10 = TEXT
10.value = <label for="uid33">Select:</label>
20 = CONTENT
20.wrap = <select id="uid33" name="tx_powermail_pi1[uid33]" size="1">|</select>
20 {
table = tt_address
select {
pidInList = 5
orderBy = name
}
renderObj = COA
renderObj {
10 = COA
10 {
10 = TEXT
10 {
field = uid
wrap = <option value="|">
}
20 = TEXT
20 {
field = name
wrap = |</option>
}
}
}
}
}