Page 1 of 1
Object Orientated Forms
Posted: Mon Jul 10, 2006 3:53 pm
by Ollie Saunders
I can't believe searches for this have come up with nothing.
Basically I'm looking for a PHP 5 (none of that PHP 4 smurf) OO form generator/validator etc.
Anyone know of a good one?
Posted: Mon Jul 10, 2006 3:57 pm
by dull1554
Hmmmm.... im surprised there isnt a class for this... i may have to start writing one
Posted: Mon Jul 10, 2006 4:03 pm
by feyd
look on php classes..
Posted: Mon Jul 10, 2006 4:04 pm
by Ollie Saunders
i may have to start writing one
No don't. I started and then I realised that it is a pretty big undertaking.
There's QuickForms which is PHP4 and there's QuickForms 2 which is PHP 5 but in development with no releases at all. Then there's patForms which is PHP 4. All of them are pretty big.
Posted: Mon Jul 10, 2006 4:06 pm
by Ollie Saunders
feyd wrote:look on php classes..
what
these?
Posted: Mon Jul 10, 2006 4:09 pm
by feyd
no... phpclasses.org
Posted: Mon Jul 10, 2006 4:30 pm
by Ollie Saunders
Nope, don't like anything on there.
And there are far too many adverts on that site.
Posted: Mon Jul 10, 2006 4:58 pm
by Christopher
What type/style of OO form generator/validator are you looking for? Perhaps we could code one here in this thread.
The problem with them in not the manager itself, but all the supporting code needed to do everything required. Lots of style and personal preference issues to overcome to get more than one programmer to agree on all that stuff. Believe me ... I know.
You can look at the ones in the Skeleton code base. The Form Controller there is build on top of an general purpose Application Controller class which is in turn build on top of a general purpose Input Controller class, plus Filter and Validator classes, and a FormField generator class, and some containers. That's sort of the way building a "OO form generator/validator" goes ...
Posted: Mon Jul 10, 2006 5:36 pm
by Ollie Saunders
The Form Controller there is build on top of an general purpose Application Controller class which is in turn build on top of a general purpose Input Controller class, plus Filter and Validator classes, and a FormField generator class, and some containers. That's sort of the way building a "OO form generator/validator" goes ...
Like I said, pretty complex.
Looks like I'm going to have to write it myself.
Perhaps we could code one here in this thread.
Its a nice idea but I won't be able to contribute because I'm up against a deadline here. So I'm just coding what I need write now. Once I've written it I'll post it here and you can all debate over it and extend it if you like.
What type/style of OO form generator/validator are you looking for?
My requirements are many:
- Valid XHTML output to HTML 4.01 spec
- Accompaning modular (many files not all required always) JS library and guidance CSS
- Doesn't attempt to replace logic, form logic is too varied and complex to ever successfully abstract, for instance validation rules of a whole groups of field may depend on the several validation tests of another, I couldn't image an OO interface capable of handling that better than procedurally.
For instance in the form below I have checkboxes in the fieldset that expand and collapse them. There is PHP logic that only checks the fields contained within it when its expanded. But of course things can get much more complicated than that.
- Compatible with, or even better, intergrates with the ZF
- Adheres to the Zend Coding Standards (a very nice set of rules to code by)
- Support fieldsets, collapsible fieldsets, help sections, textarea, selects, buttons, checkboxes, radiobuttons etc.
This is one of about 20 forms I have to make for this project all with very specific requirements:

Posted: Mon Jul 10, 2006 6:36 pm
by Roja
The title (this is a pet peeve) should have been object
oriented. Object Orientated would mean something very different.
Other nitpicks:
ole wrote:Valid XHTML output to HTML 4.01 spec
HTML 4.01 spec is for HTML. Not XHTML. XHTML would not be valid HTML 4.01.
ole wrote:'m looking for a PHP 5 (none of that PHP 4 smurf) OO form generator/validator etc.
You do realize that the difference in a PHP5, E_ALL version of the php4 code could be as small as a dozen lines of changes, instead of coding your own?
"None of that PHP4 smurf" to me translates to "I dont mind reinventing the wheel to avoid minor changes to a proven library, because of absolute standards". Might wanna rethink that.
Posted: Mon Jul 10, 2006 7:07 pm
by Ollie Saunders
The title (this is a pet peeve) should have been object oriented. Object Orientated would mean something very different.
Wow, why has nobody ever corrected me on that before?
HTML 4.01 spec is for HTML. Not XHTML. XHTML would not be valid HTML 4.01.
You can write XHTML well-formed syntax but not follow the HTML 4.01 spec. So that's what I meant.
You do realize that the difference in a PHP5, E_ALL version of the php4 code could be as small as a dozen lines of changes, instead of coding your own?
OK, again, I meant something different from what I said.
Generally people who write PHP 4 code write very procedurally; a lot of assoicative arrays. That's what I want to get away from. Instead I want a nice class hierarchy that is polymorphic and makes good use of PHP 5's data hiding capabilities as well as things like magic methods and exceptions.
What I'm trying to say really is that it need to be OOP through and through.
Posted: Mon Jul 10, 2006 7:39 pm
by Christopher
ole wrote:My requirements are many:
- Valid XHTML output to HTML 4.01 spec
- Accompaning modular (many files not all required always) JS library and guidance CSS
I'd be interested to know what libraries you are interested in. Something like Prototype? Yahoo? Google?
ole wrote:[*]Doesn't attempt to replace logic, form logic is too varied and complex to ever successfully abstract, for instance validation rules of a whole groups of field may depend on the several validation tests of another, I couldn't image an OO interface capable of handling that better than procedurally.
For instance in the form below I have checkboxes in the fieldset that expand and collapse them. There is PHP logic that only checks the fields contained within it when its expanded. But of course things can get much more complicated than that.
This can all be handled by a Rule based From Controller, but not everyone is comfortable with that style. I like it but I think I am in the minority in that.
ole wrote:[*]Compatible with, or even better, intergrates with the ZF
[*]Adheres to the
Zend Coding Standards (a very nice set of rules to code by)
Everything I do these days follows those conventions so you can use loadClass(), etc.
ole wrote:[*]Support fieldsets, collapsible fieldsets, help sections, textarea, selects, buttons, checkboxes, radiobuttons etc.
I do a lot of this already on the server side. But some of this stuff is client side code.
I am interested in creating a nice client side system to do pre-validation, effects, etc. If we can agree on the javascript library I think we could create something worthwhile. Even better would be to create a scaffolding generator that would generate matching server/client base code for the form.
Posted: Tue Jul 11, 2006 9:43 am
by onion2k
I wrote my own form framework. It's awesome .. it does every form element imaginable (including stuff like map input using Google Maps, image upload with a variety of thumbnail options like clipping, checkbox trees.. loads). It's not object-oriented though, and it's PHP4. And it's not publically available. I'd definitely recommend writing one.. lots of fun.
Posted: Tue Jul 11, 2006 9:47 am
by onion2k
ole wrote:Generally people who write PHP 4 code write very procedurally; a lot of assoicative arrays.
You need to remember that form data when it gets back to the server is already in associative array format .. you can't get too far from that, even in PHP5.