NYCPHP Meetup

NYPHP.org

[nycphp-talk] Form Generation and Processing

Mark Armendariz nyphp at enobrev.com
Tue Jan 6 14:00:36 EST 2004


Now that I'm finally back to work, I've taken a look at my framework and
decided to take it all apart and put it back together again for the 1500th
time.  I figure some of you can relate (humor my sanity).
 
My latest idea for an addition came to me from a recent project.  I work
with a few very talented designers and I want to give them as much control
over the forms as possible on the site.  I personally avoid template systems
and just go the php var route, and try my very BEST to keep the absolute
minimum of php code inside the html (besides vars and basic conditionals).
 
What I ended up doing for the form was set it all up in html and created a
class (super basic now while testing the idea - no error checkingor anyhting
yet) for setting the values of the form fields.  I'll be using ADOdb, so for
new forms, I grab all the field's default values from the db.  For
edit/update forms, I grab the record's data, and for errors, I replace the
form values array with the $_REQUEST array.  So I give the designer a list
of form fields and he puts them where he wants.  The 'save' script uses
adodb's update and insert functions to update only the form values passed,
which essentially allows the designer to remove form fields as they please.
 
Working example:
http://www.enobrev.com/form/index.php
<BLOCKED::http://www.enobrev.com/form/index.php> 
 
Code of example:
http://www.enobrev.com/form/index_code.php
<BLOCKED::http://www.enobrev.com/form/index_code.php> 
 
Code for basic class, thrown together for testing the idea (in otherwords,
just an idea):
http://www.enobrev.com/form/class_code.php
<BLOCKED::http://www.enobrev.com/form/class_code.php> 
 
So am I completely insane in thinking a designer would understand adding
vars like that to their html?  I know I should ask them and I plan to as I
figure out how it will all work, but I'm also asking you guys as
professionals about what you think of the idea of form control without
actaully controlling the form output, only the names and values (and
optionally the options of a select).
 
I've seen lots of classes which generate the actual form inputs / selects
and what not, and I figured that best left to the designer.  That's what
they do.  I figured controlling the names and values of the fields
(including checked/selected), was all that was really required.  AND
possibly control the labels as well, but that's NOT mandatory and strictly
in case of error for added formatting (for the designer to control via cms
maybe?).
 
So um.. does doing it this way make sense?  I ask as my time is short in
general and I'd hate to put a few weeks into an idea that's been tried
thousands of times and failed.
 
Thanks!
 
Mark
ny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040106/dcd97012/attachment.html>


More information about the talk mailing list