[PHPLIB-DEV] The future of oohform From: Ulf Wendel (UW <email protected>)
Date: 12/02/99

Good morning!

I didn't give up to work on oohforms. Have a look at
http://projektordner.dev.netuse.de/index.php3 to see what I've
done.

+++ Changes to oohform.inc

oohform got a new function:
list ( $error_msg, $error_flags) = $form->ext_validate(
$default=false, $vallist="", $delimiter="\n")

The function has some differences to $form->validate():

- form->validate() stops at the first error
- form->validate() returns first error (valid_e, length_e etc.)
it can find

- form->ext_validate() validates all elements, mentioned in
$vallist or all elements in the form
- form->ext_validate() returns an array
- the returned array contains $error_msg =
$valid_e_1.$delimiter.$length_e_2...
- the returned array contains $error_flags = array ( "elname" =>
"validation error")

+++ New ooh_to_tpl.inc

Preface: This is really dirty code - unefficent and bloody, but
most of it works...

About:
Oohforms is beautiful but I doubt you can really save time with
it. I was always missing a kind of wrapper between oohform and
template. Yes, I could write $form->add_element(),
$form->get_element(), $tpl->set_var() but these are three lines
of code. I wanted to write one line $wrapper->add_element() and a
blue box does the rest for me. That's what's ooh_to_tpl for.

I had a closer look at several of my forms and noticed that they
all have a common look. One line typically looks like:

{TITLE} {STATUS_SIGN} {FORM_ELEMENT}
{HINT} {ERROR_MESSAGE}

+ add_element()
The well known add_element() got some new attributes: title,
sign, hint and error. sign and error are usually automatically
generated and set with help of the new form->ext_validate()
function.

+ add_comment()
add_comment() is some kind of shorthand to add_element where
{FORM_ELEMENT} ist substituted by the comment

+ add_reset(), add_sumbit()
Featurelimited shorthands for add_element()

+ start(), finish(), get(), freeze()
equal to oohform. Maybe one difference. You can call get()
without previously calling start().

+ start_block(), end_block()
This tells the wrapper that all elements added by add_element
(except for type hidden, button, comment) between a call to
start_block() and end_block() form a block . You'll see what
block means by looking at the pizza stuff on the webpage. (Yes, I
know it has a little bug...)

+ color_flash()
Who can tell me a better name. Colors every nth line of by the
colors given in an array.

+++ What is it good for?

This wrapper is the base for what's shown at the end of the
webpage. Excacly one line could dump a whole database table to
well designed form $db_magic->show_table( "abisz_eintraege").
It's a ten minute hack based on ooh_to_tpl and db->metadata().
One fine day we could hold an etxtra table in our database and
get beautiful forms without typing a whole day...

Request for Comment.

Ulf

-- 
Ulf Wendel
NetUSE Kommunikationstechnologie GmbH
Siemenswall, D-24107 Kiel, Germany
Fon: +49 431 386435 00  --  Fax: +49 431 386435 99
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.