Page 1 of 2

A little project ive been working on, please critique

Posted: Fri Feb 11, 2005 2:46 pm
by bg
This is a little project ive been working on for the last couple days. Maybe if it catches on I'll GPL it. Anyway, I'd like to have some people with experience critique the code and the way its done. Also feel free to contribute code or ideas.

I wanted to create some classes to handle html forms. A good portion of my coding goes into validating forms, getting data from them, setting their values from $_POST, etc. I figured why not create a class to handle all of that.

So far, this is what it does:

-Renders all form objects (XHTML)
-Crude handling of how form objects are displayed on page
-handles $_POST and will use those values if told to do so

What I'd like it to do in the future:

-Client side validation
-Server side validation

Some cool features are:
-Some inputs (right now, text and checkbox inputs) can be defined as multiple and will be created as input arrays.


And what currently needs to be improved/redone:
-layout handling, should use CSS instead of current method

Heres a brief description of how it works:

There are the input objects (input_text, input_select, input_textarea, input_checkbox, input_radio), the fieldset object, and finally the form object. The fieldset object contains a collection of inputs, and the form object contains a collection of fieldsets.

Most of the dirty work is done in the input objects. I used an abstract input class to keep the input objects as uniform as possible, but obviously each input required a lot of its own code because of how values are handled in the different inputs.

The fieldset object is very simple, its primary function is to serve as a nice way of organizing fields.

the form object is also pretty simple, but only because it doesn't implement a lot of the features I hope for it to eventually have.

Heres a zip of the files, make sure they're all in the same directory when you test.

Form Objects

BTW, this code requires PHP 5.

Thanks.

edit: index.php contains the test code. Viewing that first would be a good start.

Posted: Fri Feb 11, 2005 3:56 pm
by timvw
I have had only a very brief look at your code so i'm not sure, but i think this: http://pear.php.net/package/HTML_QuickForm is the same as your project (but on steroids :))

Posted: Fri Feb 11, 2005 4:13 pm
by bg
timvw wrote:I have had only a very brief look at your code so i'm not sure, but i think this: http://pear.php.net/package/HTML_QuickForm is the same as your project (but on steroids :))
but its not written in php 5!! :D

Posted: Fri Feb 11, 2005 7:12 pm
by timvw
thus it's more flexible than yours... :P

Posted: Sun Feb 13, 2005 7:41 am
by Maugrim_The_Reaper
If it's written in PHP5 - doesn't make it perfect. How many hosts are actually running PHP5 to date? PHP4 is still the king until hosts migrate...

Posted: Mon Feb 14, 2005 10:28 am
by andre_c
I would say a php4 script is more portable, not necessarily more flexible.
but i guess that depends on the definition of flexible

Posted: Mon Feb 14, 2005 11:29 am
by Maugrim_The_Reaper
It meets both definitions until PHP5 is more widely adopted. If someone releases a PHP5 app tomorrow morning, just how flexible will it be when I go to upload it to my host? :)

j/k, php5 IS more flexible, but there's little advantage to using it's full potential until it's standard...

Posted: Tue Feb 15, 2005 3:45 am
by patrikG
php5 IS more flexible, but there's little advantage to using it's full potential until it's standard...
the chicken and egg situation...

Posted: Tue Feb 15, 2005 2:38 pm
by bg
my host runs php 5, but then again, im the sys admin. :D

Posted: Sun Feb 20, 2005 10:20 pm
by smpdawg
Ignore the nay sayers - you will just be further ahead of the curve than they are.

BTW - I am working on a similar system in PHP5, nice to see my competitiion. :D

Posted: Mon Feb 21, 2005 10:49 am
by bg
smpdawg wrote:Ignore the nay sayers - you will just be further ahead of the curve than they are.

BTW - I am working on a similar system in PHP5, nice to see my competitiion. :D
Cool, id be interested in seeing it :D

Posted: Mon Feb 21, 2005 11:07 am
by bg
Maugrim_The_Reaper wrote: j/k, php5 IS more flexible, but there's little advantage to using it's full potential until it's standard...
Might be a problem for client side software, but not the case with PHP. If you were to start writing a php app right now, don't you think it would make more sense to write it in PHP5, since eventually it will be the standard?

Posted: Mon Feb 21, 2005 11:10 am
by markl999
PRADO might be worth looking at for some ideas. I'm using it almost exlusively now :o

Posted: Wed Feb 23, 2005 10:06 am
by bg
markl999 wrote:PRADO might be worth looking at for some ideas. I'm using it almost exlusively now :o
looks sweet. definatly looks like something id like to use

Posted: Sun Feb 27, 2005 12:21 pm
by smpdawg
bgzee - I downloaded the zip and took a look at it. It looks good, clean and easy to read. I think you need to start over. :wink:

Seriously though, are you going to continue working on it or jump ship to Prado? I have to admit that I started looking at Prado a few months ago and it is impressive.

The reason I have stuck with my own framework is:

1. I started it over a year ago and I have a lot of time invested in it.
2. I have a different goal for my project.