A little project ive been working on, please critique
Posted: Fri Feb 11, 2005 2:46 pm
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.
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.