* Simon Willison posted this week about getting form validation info from extra HTML tags: http://www.codingtheweb.com/projects/newslog/article/1_75047.htm
Interesting post. It was the original plan in flexy to use this type of tag'ed validation:
eg.
<input type="text" flexy:validate_rule="month|122000|122003">
but I gave up in the end as it became totaly impracticale to maintain this type of structued data within HTML forms.
The final solution (albeit still being played with) ended up a bit like this....
HTML_Template_Flexy (in CVS) will generate a
templatename.html.element.serial file for all html pages that have forms (or use the flexy:dynamic attribute)
this can be read by unserialize(file_get_contents(...)) by any application and contains an array of
[element_name_or_id] => HTML_Template_Flexy_Element (
[tag] = input
[attributes] => array(
"name" => "fred_blogs"
"type" => "text"
)
... (+ a few more..)
At this point you could still use your own application to read these serial files, and read validation tags if you want..
However, I wrote a little php-gtk aplication, that reads all these element files, and allows you to assign a number of 'rules' to each one.. (just pick from a list of names), and fill in an error message.
these rules just being methods of a user defined class..
The second part is a rule class maker, that is just a simple interface to writing a validation class (eg. return true or false if something validates ok)..
It has a little 'hint'er for using pear's validate class, so you can quickly pull in and understand everything in that class..
The codes in here. (the ValidateMangaer.php is the php-gtk application.
http://www.akbkhome.com:81/svn/akpear/Gtk_ValidateManager/
The code that does the validation at runtime
http://www.akbkhome.com:81/svn/akpear/Gtk_ValidateManager/ValidateManager/Base.php
which is increadibly simple...
An example of a generated validate class: (warning - a little messy)
http://www.akbkhome.com:81/svn/hebehaven2/ValidateHebe.php
from the wddx config file.
http://www.akbkhome.com:81/svn/hebehaven2/ValidateHebe.php.wddx
A simple rule file for a template..
http://www.akbkhome.com:81/svn/hebehaven2/templates/browse/account_code_list.html.rules.wddx
This provides a realitively simple example of it..
http://www.akbkhome.com:81/svn/hebehaven2/Hebe/backend/rentals_edit.php
Regards
Alan