In pico-1.52, the spec of formmail system has been fixed.
Then, I'll write example codes.
Look again the skelton.
<{capture}>
<form>
(describe form parts)
</form>
<{/capture}>
<{formmail}>
<{capture}>
<form>
<input type="checkbox" name="Favorite_Fruits" value="Orange" />Orange
<input type="checkbox" name="Favorite_Fruits" value="Apple" />Apple
<input type="checkbox" name="Favorite_Fruits" value="Pear" />Pear
<input type="submit" value="Confirm" />
</form>
<{/capture}>
<{formmail}>
<{capture}>
<form>
<fieldset>
<legend>Favorite Fruits</legend>
<input type="checkbox" name="favorite_fruits" id="favorite_fruits_orange" value="Orange" /><label for="favorite_fruits_orange">Orange</label>
<input type="checkbox" name="favorite_fruits" id="favorite_fruits_apple" value="Apple" /><label for="favorite_fruits_apple">Apple</label>
<input type="checkbox" name="favorite_fruits" id="favorite_fruits_pear" value="Pear" /><label for="favorite_fruits_pear">Pear</label>
</fieldset>
<input type="submit" value="Confirm" />
</form>
<{/capture}>
<{formmail}>
In pico-1.51, the rule for "Form validated by HTML" has been changed radically.
read (1)~(3) again, please.
These are the new rule of the system for HTML designers.
Name of the field
It is "name" attribute.
You can also use linear array by just adding [] after the name.
eg) name="favorite_fruits[]"
Title of the field
The 1st option is <label> corresponding the <input>.
While the 1st option for "checkbox" or "radio" will be <legend> inside <fieldset></fieldset>
2nd option is "title" attribute in the tag.
Last option is "name" attribute in the tag. (same as Name)
essential
Specify it by class attribute.
eg1) <input ... class="required" />
eg2) <input ... class="required int" /> // "int" AND "required"
Type
Specify it by class attribute.
Only a type can be valid.
- int
-- filtered by intval()
- double
-- filtered by doubleval()
- singlebytes
-- filtered by mb_convert_kana( ... , 'as' )
- email
-- checked by RFC2822. an error will be raised if it is invalid.
- telephone
-- characters unused as telephone number will be removed.
Here is a document how to validate POST data via pure HTML.
(A) How to get POST's indexes should be received?
Just get "name" attributes in the HTML.
# Though it is difficult to treat array like hobbies[], I skip it now.
(B) How to get field's title?
This system gets field's title from <label> corresponding the <input> from HTML.
(C) How to judge whether the field is essential or not?This system judges them by their filed's name.
If a field contains '_required' in its name, the field will be regarded as essential.
refer the sample HTML in (1).
The field of 'name_required' is essential.
You can specify validation rule by "class" of <input>. (pico >= 1.51)
refer the sample HTML in (1).
<input> for 'name' has the class of "required".
Then the field will be essential.
(D) How to do "TYPE-SAFE" or "TYPE-AUTO-CONVERSION"?
This "type" contains not only int,double,string etc, but also "telephone number","email address" etc.This system judges them their filed's name like (C).
eg) if a field contains 'email' in its name, the field will be validated as "email address".
You can specify validation rule by "class" of <input>. (pico >= 1.51)
refer the sample HTML in (1).
<input> for 'email' has the class of "email".
Then the field of 'email' will be checked by the rule of RFC2822.
Of course, you can specify classes multiply.
If an <input> has class="email required", the field will be essential AND validated as "email address".
The sample code shown in yesterday can be simplified like this.
<{capture}>
<form>
(form controllers)
</form>
<{/capture}>
<{formmail}>
I implemented "Formmail validated by HTML" for pico 1.50
You may ask "What is new?"
OK.
This system uses Template data written by HTML designer as "Validator".
You need not XML definition etc.
And I don't value the module like liaise or class of XoopsForm, because such HTML generating system kills the liberty for HTML design.
I believe this system makes both designers and programmers happy.
Anyway try to make a contents like this.
Filters: Turn 'Smarty(XoopsTpl)' on.
All of the rest options should be turned off.
(Also "body cache")