[thelist] CF (SQL?): query.columnlist

Isaac Forman isaac at members.evolt.org
Tue May 22 23:45:39 CDT 2001


judah,

funnily enough, i'm working on something very similar to automate building
forms and writing to the db. the way i'm doing it is using a table (FIELD)
to define what elements each item will require.

FIELD
id
typeid (foreign key)
name (name of field in db)
form (which form element to use: text, date (day/month/year dropdowns),
richtext, smalltextarea, largetextarea)
datatype (date, memo, integer, text)
title (appears above the form element in the edit template)
info (appears in small text below form element - used to pass warning/alert
msgs)
maxlength (defines maxlength for text inputs)
validate (not being used currently, but defines the validation method to
use)

there is probably one intermediate step on top of your method, but i imagine
the advantage would be the ability to specify validation methods (ie,
validate a text string as a phone number or email address), maxlength, title
and info.

so far, it appears to be working fairly well. i can add a table to the
database, define the fields in the FIELD table, and all of the displaying,
editing, updating, adding, etc are all taken care of. much less hassle than
the way i was doing everything originally.

for example, if i have a TYPE of "User", they might have various fields -
firstname, lastname, email, password, phone, mobile, info, etc. for each of
those fields, there is an entry in the FIELD table with typeid equal to that
of the user type.

currently, the form elements are output in the order the fields are added to
the db, but it would be very easy to add another ranking/sequence column
that would allow you to specify the ordering.


isaac





More information about the thelist mailing list