Hey there,

In my form generator I separate the data and the form generation. I have
a header file that is included using fileExists() that populates the
field data and then the form is generated using the default settings if
the variables are not populated or are ''. I also use a session variable
to pass the filled in data back to the previous page which runs after
the data is populated to repopulate the table (another essay for another
day)

A little detail...

I have a table for forms, I have a table for form fields and I have a
table for lists that are used around the site, which is also used for
select lists/checkboxes/radio/etc. Each formfield is customisable
including class and style, display order, events (onClick=), field
sizing, validation (triggering server/client scripting) and various
custom types (such as textboxdate(with datepicker),
textboxcurrency($1,111.00), text (plain text or slap a class on it and
bam it's a heading!) buttonsave(cancel,save,reset buttons, muliple
linked selects (by combining three fields and a 'script' field and of
course wysiwyg1 and 2 (fckeditor and htmlarea). Basically in the last
three years it's become a very sweet, sweet piece of <10ms (on my dev
server) code for an entire form...

Some Notes

- Optimise, Optimise Optimise, a fast form's a good form!

- A variable is delared for each form (eg: formData.thisForm) - this
also allows for these variables to be used elsewhere in the logic if
required on the page. I name the form for ease of programming when you
want to use form variable data to calculate something. You could also
use an array formData[1], but you lose the readability of code.

- A query that loops over the dataset and dumps all of the field data
using (query.columnlist) into the variables for each field (eg:
form.thisForm.firstname)

- Use regex on server/client(javascript) to validate your input (use
"regex buddy" in Perl mode) and use charity Khan's javascript regex
script (builder.com superscripter) - also check out her form validation
megascript as a concept if it's still around... Or just use qforms or
alike for js side.

- The framework allows you to drop pretty much anything into a form, for
example I drop sortable tables with radio/checkboxes into forms all the
time. So the form has three fields: 1) the form heading (if applicable),
the sortable table and a submit/reset combo buttonset.

So the low down:
1) Query Form Data
2) Query Field Data * (includes defaults for fields)
3) Query Data for specific record + loop over columnlist to create
variables
4) Loop over re-populate session variable (if defined)
5) Loop over fieldset and if data is not '' then set defaults from field
data table

* I query these separate as if (for some reason) there are no fields in
a form it can still populate the form data (ie if you include a template
that has some custom form inside a blank form)

Hope this makes sense...

Chris Dawes

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chad
Renando
Sent: Wednesday, 8 June 2005 3:38 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Form Advise.

I initially started going down the path of storing my form field data in
an array and processing the array in my presentation layer.  I found I
was adding heaps of complexity  just to try to adhere to my home-grown
MVC framework, and ended up just processing the information straight
from the query.

When storing the form field presentation data, you still need to query
twice in order to get the Value data for the form when using it to edit.
I found I was querying to get form field parameters, querying to get the
data, then trying to get tricky / loopy with aligning data from both
queries into an array just so I could loop through my array and present
the information.

Be interested in others thoughts specific to:

A. Storing data into an array just so you can loop through the array in
your presentation (pro: encapsulates all your data into a single array
for simplicity of code / con: adds extra loop just to create the
array)

vs.

B. Building the presentation straight from the query
(pro: lass processing / con: not as elegant)

Chad
who is concerned now that he has mentioned fish net and used the word
elegant

On 6/8/05, Jeremy <[EMAIL PROTECTED]> wrote:
> Hi Ricardo,
>
> Yeah thats what I'm upto at the moment or at least my thoughts are up
> to that level. I have just been playing around with arrays and putting

> all the data into that but i reckon its going to be a pain in the ass.
>
> Interesting on the Checkboxes, and radio stuff. Do you have an example

> of this you could show me or is is IP encrypted...hehe.
>
> Its funny, everyone who responded off list and on list...are
> saying...whoooa...yucky pucky jeremy....
>
> thanks for your help!!
>
> Jeremy
>
> > jeremy,
> >
> > most of our application is based on forms that are generated from a
> > databas= e.
> > all of the fields are able to have a default value.
> >
> > For check boxes, radio groups and selects i pass a list as the
> > default value, loop over it to get the options.
> >
> > Ricardo.
> >
> >
> >
> > On 6/8/05, Jeremy <[EMAIL PROTECTED]> wrote:
> > > Hi guys and gals,
> > >=20
> > > I'm about to attempt building a dynamic form based from a
> > >database. I wan=
> > t
> > > to make it as simple as possible for both user and my brain. Has
> > >anyone  done such a thing. My issue so far is being radio boxes and
check boxes.
> > >=20
> > > If anyone can point me in the right direction that would be nice.
> > >Below i=
> > s
> > > what I have so far. I also played around with Flash vs. XML
v-cool.
> > >=20
> > >=20
> > > <cfform name=3D"form" method=3D"POST" format=3D"FLASH" 
> > >height=3D"400" wi=
> > dth=3D"400">
> > >                 <cfformgroup type=3D"accordion">
> > >                         <cfformitem type=3D"HTML">Please enter
> > > your </cff=
> > ormitem>
> > >                                                 <cfoutput
> > > query=3D"GetInf=
> > o">
> > >                                                         <cfif
> > > #FormRequir=
> > ed# IS 1>
> > >                                                                
> > > <cfset RV=
> > alue =3D "Yes">
> > >                                                         <cfelse>
> > >                                                                
> > > <cfset RV=
> > alue =3D "No">
> > >                                                         </cfif>
> > >                                                         <cfif
> > > #formtype# =
> > IS 'CheckBox'>
> > >                                                                
> > > <cfformit=
> > em type=3D"HTML">#Question#</cfformitem></cfif>
> > >                                                         <cfinput
> > > type=3D"=
> > #formtype#" name=3D"#formname#" value=3D"#formvalue#"
> > label=3D"#FormLabel#"=  required=3D"#RValue#" message=3D"Please
> > Check #FormLabel#">
> > >                                                 </cfoutput>
> > >                                                 <cfinput
> > > type=3D"Submit" =
> > value=3D"Submit" name=3D"Submit">
> > >                         </cfformgroup>
> > >                 </cfform>
> > >=20
> > > jeremy
> > >=20
> > > ---
> > > You are currently subscribed to cfaussie as:
> > >[EMAIL PROTECTED]  To unsubscribe send a blank email to
> > >[EMAIL PROTECTED]
> > m.au
> > > Aussie Macromedia Developers: http://lists.daemon.com.au/
> > >
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To

> unsubscribe send a blank email to
> [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
>

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

----------------------------------------------------
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this email in error please notify the system manager. Please 
note that any views or opinions presented in this email are solely those of the 
author and do not necessarily represent those of the company. The recipient 
should check this email and any attachments for the presence of viruses. The 
company accepts no liability for any damage caused by any virus transmitted by 
this email.
----------------------------------------------------

---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to