Object Orientated Forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Object Orientated Forms

Post 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?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

Hmmmm.... im surprised there isnt a class for this... i may have to start writing one
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

look on php classes..
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
Last edited by Ollie Saunders on Sat Aug 05, 2006 5:24 pm, edited 1 time in total.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

feyd wrote:look on php classes..
what these?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

no... phpclasses.org
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Nope, don't like anything on there.
And there are far too many adverts on that site.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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 ...
(#10850)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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:
Image
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

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