|
Posted by Richard Levasseur on 08/09/06 09:11
oliver.saunders@gmail.com wrote:
> I'm looking for help with project. I have written a detailed post about
> it.
>
> Please see:
> http://forums.devnetwork.net/viewtopic.php?t=52753
To be honest, I've yet to find a good forms class that lets me do
things the way i want without to much hassle.
I've tried to design and plan my own form suite, but there are always a
couple of inherent problems I run into that are always at odds:
1) Presentation. Most forms autogenerate the html and spit it out.
Meanwhile, i have to manually set dozens of attributes for each element
of it to get it to have css classes even resembling something i can
style. The end result is I write just as much code using the API as I
would have writing raw HTML.
1a) Complex Presentations are hard to generate using a simple API. Ex:
your date object. IMO, having 3 fields they fill out is ugly, and it
can actually be faster to write mm/dd/yyyy instead of "type - click -
type -click -type", even better is having a javascript calendar, or
maybe its limited by the year, and you dont' care about the month.
The point is, that one input field can be displayed dozens of ways,
each one requiring some nuances.
1b) Label and input relations. Most forms can be divided up into a
table (not that its the best way, but for ease of explanation, think of
a grid layout). Where do the labels go? How far do they span?
Sometimes a simple [Label | Input] layout isn't conductive or feasible
space wise. Maybe I want the label on the right. Maybe I can't put
the label anywhere *but* the right. Maybe it goes above and spans
multiple rows. Maybe its not really a label, but just a header for
group of inputs. You see the problem? It gets complicated really
easily.
2) Logic: Most form classes have inadequate logic processing rules and
abilities for my tastes or circumstances. Sometimes things depend on
things depend on other things, and then those things need to change
other things or invalidate more things etc etc. the pear QuickForm
isn't so bad, but I can't stand the pear style of coding with the
isError() methods and such. PITA.
3) Tries to tie together too many things. A lot of form things i find
like to mix and match presentation, logic, and data stuff all into one.
All those should be seperate. I should be able to mix and match any
combination of them.
4) Don't use PHP5 abilities. Everything I see still uses masses of
arrays and operations on arrays of data. Objects, people, objects.
They let you do all that but you don't have to pass all that data
around or worry about indices being set or any of the inherent and
frustrating difficulties dealing with arrays. PHP doesn't need to go
creating copies of it all. You can reference that same data from other
places without using & or having to store some sort of key lookup or
implement some sort of trigger to lookup the current value and bla bla.
4a) Exceptions! Yes, I know a logic error in a form isn't the best use
of exceptions, but the concept is what i'm getting at. If there is an
error in a form I want to be able to simply get a value back and be
able to use the error to operate directly on that field. I don't want
to have to look it back up in the form then execute custom code:
foreach($err as $e) { $e->field->setErrText($e->getMsg()); } See?
Wasn't that easy? I just marked every invalid field with its specific
message.
Its a good start, but don't:
* Combine presentation with business logic.
* Combine data logic with the form. (the form does database
update/delete, etc)
* Force a specific presentation. (new Input("Label", "name") always
displays the same)
* Limit validation abilities
</rant>
Navigation:
[Reply to this message]
|