Re: [PHPLIB-DEV] Some ideas on tpl_form From: Kristian Köhntopp (kris <email protected>)
Date: 12/17/99

Michael Haertl wrote:
> - After form submission, there's a database query and
> i show a "list page" of all names in this town.
> Every name on this list is linked to something
> like "edit.php3?id=5"
> Somewhere you got a button for new entry which is a link
> to edit.php3?id=new.

A table editor should always offer the optional ability to
work on more than one item at a time. That is, you should get
a table dump of the form the Table class provides using the "check"
option:

+-----------------------------------------------+
| | Name | Given Name | Comment |
+-----+-------------+------------+--------------+
| [ ] | Koehntopp | Kristian | Blah |
| [ ] | Sampleman | Gabrielle | Barf |
+-----+-------------+------------+--------------+
| Delete Edit New |
+-----------------------------------------------+

One should have the option to check multiple entries in this
table and then hit Delete or Edit. Delete would (optionally ask
for confirmation and) delete all selected entries. Edit would
bring up an edit screen with repeated edit forms for all selected
entries. New will bring up a single input form giving you ability
to enter a new datum.

Also, each line can be a link or have a link which is a shortcut
to selecting only this line and hitting edit.

This is faster and much more ergonomic than a single action
form.

> So i think when a form has to be displayed there are 3 common cases how
> the default form values should be set:

You are missing the delete case.

> 3. error in form validation:
> show user input values as default
> default_values = variable_values

Also missing: Have any number of error messages per input field.
Display all per-field error messages AT THE FIELD.

Also missing: Have any number of inter-field error messages (such
as "Checking the credit card checkbox requires that you provide a
valid credit card number"). Display inter-field error messages
at the form.

> So what i missed in tpl_form is a function which gathers the default
> values from a db just like get_default_values() does from the submitted
> variable values.

Gathering is one thing, scattering the other. Also, often you are
editing not a single table, but the result of a join of multiple
tables. You need to be able to scatter the input result back into
the originating tables, transactionally.

Also, the above table is a plain detail table, which is okay for
small tables (not many columns). For more complicated cases you'd
have a different display (cascaded master-detail navigation) and
you'd need more control about the layout of the details.

All of this is not done in a single class or call. Ulf Wendel
and Jan Kneschke are currently working on a set of classes which
is doing this (for SQL and LDAP) and which will provide a more
thourough forms driver logic (uw <email protected>, jk <email protected>).

Kristian

-- 
Kristian Koehntopp, Knooper Weg 46, 24103 Kiel, +49 171 2231 811
"Da kann Deine Nummer 1 naemlich ganz lieblich Fruehstueck machen.
 Und Fruehstueck, ey, da stehst Du doch auf."

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