Formmail validated by HTML (5)

Date 2007-09-15 06:01:46 | Category: XOOPS

in englishin japanese
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}>


Now, try a checkbox.

<{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}>

This is the simplest pattern.
You should check "Favorite_Fruits" instead of "Favorite_Fruits[]".
(Of course, you can also use "Favorite_Fruits[]" there)
With this system, you need not add [] after "name" attribute.

You can write better form HTML like:

<{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}>

With this example, you can get the field's title as "Favorite Fruits" instead of "favorite_fruits".
Only checkbox and radio get their field's title from <legend>. You can use ' ' for field's title.

With upper example, you can get the field's title from "name" attribute.
Then, you cannot use ' '(space) .




You can read more news at PEAK XOOPS.
http://xoops.peak.ne.jp

The URL for this story is:
http://xoops.peak.ne.jp/md/news/index.php?page=article&storyid=441