PEAK XOOPS - News in englishin japanese

Archive | RSS |
  
Poster : GIJOE on 2007-09-15 06:01:46 (10529 reads)

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) .


Poster : GIJOE on 2007-09-08 18:16:34 (9388 reads)

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



Poster : GIJOE on 2007-09-06 06:31:17 (9758 reads)

in englishin japanese
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".


Poster : GIJOE on 2007-09-05 05:45:07 (9897 reads)

in englishin japanese
The sample code shown in yesterday can be simplified like this.


<{capture}>
<form>
	(form controllers)
</form>
<{/capture}>
<{formmail}>

You have to check the skelton.

"The plugin <{formmail}> parses the form HTML captured by <{capture}> block. Also <{formmail}> receive POST and store SESSION. Then <{formmail}> outputs rewritten form HTML"

eg) <form> will be added proper attributes of "action" and "method".
Of course you can specify action and method by yourself.
<form action="/modules/pico/form.html" method="POST">

You can write "form controllers" as you like.
But you should follow the rule of XHTML.

- write tags with small letter
- write `selected="selected"` fully instead of `selected`
- close the tags like <input .... />
- write <label> corresponding each inputs.

<{formmail}> judges <label> as the title of the input.
The title for an input without <label> will be its "name" attributes.

You can write default values as you like. they are overwrite automatically.

This documentation is for HTML designers.
(3) will be a documentation for programmers.

0 comments

Poster : GIJOE on 2007-09-04 06:00:47 (15734 reads)

in englishin japanese
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")

Read more... | 1319 bytes more |9 comments

« 1 ... 4 5 6 (7) 8 9 10 ... 37 »
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!