|
Posted by kicken on 10/09/93 11:20
Peter Salzman wrote:
> Hi all,
>
> I'm sure lots of people have tried to abstract HTML forms using PHP classes.
> It seems like a natural thing to do.
>
> Any ideas on how to make the code more compact?
>
> Thanks for reading down this far. ;-)
>
> Pete
There are more implemtation of form element abstrations around, but I
havn't used any so I don't know exactly where they are.
However, abstration isn't always about less code, sometimes it's about
convience. For instance, in your class you eliminated the HTML from the
main script, and it's created by the output function. Thus, your main
code is less cluttered with HTML, and more direct processing.
I tried implementing the HTMLDom once using php classes, and it works
ok, but I think the effort was probably in vein as creating even the
simplest of things becomes a really large pain using the DOM structure.
I started making a few abstract methods for common items (like a
select box) but eventually decided it wasn't worth in.
Something like what you have now is useable though. It's pretty simple
and seems like it's fairly easy to use. The # of lines in the end may
be the same, but the code probably looks better.
Navigation:
[Reply to this message]
|