My site, www.logiforms.com, does this exactly. Im a bit pressed for time,
but I can explain a bit about how we do it.
There are 6 standard field types,
(textinput,radio,checkbox,select,upload,textarea). For each field, we
assign a value 1 through 6. We have a directory labelled fieldtypes, and
within the directory we have folder 1 through 6. For each fieldtype, 1
through 6, there are a number of CF templates that relate specifically to
that field type. Before I tell you what those templates are, I'll briefly
describe how we store the structure of the form.
We are using a list, delimited by a pipe char, to store the form
description. We use a client variable based system and found it faster to
use lists that to use complex data types and convert to WDDX on each page
for compatibility with DB storage. So we have a big long list, where each
position in the list is a field element. Within each list element is
another list, which contains the attributes specific to that field element.
You could also do this with XML, but that was also slower that using lists
and that converting to an array. It is generally faster to convert the list
to an array prior to getting and setting items in the list.
So you have these expected 'attributes' for each field (this is shortened
list of attributes):
1. fieldtype (1-6)
2. caption
3. fieldname
4. validationOption
5. Position
6. .....
10-20 - reserved for options specific to the field type
All lists are the same size, and elements between 10-20 are specific to the
field type as referenced in the 1st position.
So, now, when you want to display the form you loop over the formString
(using the Pipe Delimiter):
<cfloop list = "myFormStringList" delimiter="|" index="i">
<cfset formItem = listtoArray(i)>
<!--- now you have an array of the individual form field item. To
display this form element
use the template specific to it --->
<cfinclude template = "fieldtypes/#formItem[1]#/dsp_formelement.cfm">
</cfloop>
Inside the template fieldtypes/#formItem[1]#/dsp_formelement.cfm, you can
handle the parsing of options specific for each field and the display of
each field type. Each field would also have a template for 'packaging' the
field options after they were edited by a user. The standard element
options (in this example, 1-10) can be easily packaged using a common
template, and then options 10-20, would be packaged using a template like
fieldtypes/#formItem[1]#/act_packageSettings.cfm. You could also have a
template for displaying the editable field properties:
fieldtypes/#formItem[1]#/dsp_fieldSettings.cfm which could be shown in
conjunction with a common field settings template page.
I'm finding this a bit hard to explain, I hope it makes some sense and give
you some ideas....
Brook Davies
logiforms.com
At 09:20 AM 8/12/2004, you wrote:
>Wow, I did not think that I would get such range of responces. Let me
>tell you what I was looking to do in more depth.
>
>1. Have a screen where they put in the name of the question and what type(
>i.e. Checkbox, text, password, list/menu.).
>2. Then click on a submit button.
>3. This is added to a table setup for questions that has the name and and
>Type of question.
>4. Next lets take a text question. It would ask for the text you want
>displayed before the text box. it would ask if this is a multiline (text
>box) or single line. It would also ask for priority of the question,
>Width, Max Characters(only on Single Line),Number of Lines(Multi Line
>only.), Value, and Wrap(Multi Line only).
>5. fill in and click on the submit button.
>6. added to the database.
>7. Then I would also need an editor to be able to make changes to the
>question or delete it.
>8. Repeat steps for all other types of form elements.
>
>Adding them to the form.
>
>1. do a cfquery to get questions for form and sort by order.
>2. display questions by priority
>
><form>
>
><table>
><cfoutput query=Questions>
><tr>
><td> #Question#
></td>
><td>
><input type="#type#" name="#name#" size="#textsize#" value="#textvalue#"
><cfif #textType# is 'multiple rows'>textrows="#textrows#"
>wrap="#textwrap#"><cfelse>Maxlength="#textMaxChars#"</cfif>>
></td></tr>
></cfoutput>
></form>
>
>Granted that this is a very simple example. But this is what I have been
>working on and was wondering if anyone has done something like this
>before. The client will not be doing custom forms, just custom form
>elements.
>
>Jim Louis
>
> >The preferred method in Mozilla is by DOM, that means using
> >createElement. For IE currently insertCell and insertRow are preferred
> >
> >Micha Schopman
> >Software Engineer
> >Modern Media, Databankweg 12 M, 3821 AL Amersfoort
> >Tel 033-4535377, Fax 033-4535388
> >KvK Amersfoort 39081679, Rabo 39.48.05.380
>
>----------
>[<http://www.houseoffusion.com/lists.cfm/link=t:4>Todays Threads]
>[<http://www.houseoffusion.com/lists.cfm/link=i:4:174099>This Message]
>[<http://www.houseoffusion.com/lists.cfm/link=s:4>Subscription]
>[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=905.825.4>Fast
> Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings]
>[<https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion&business=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick>Donations
>and Support]
>
>----------
><http://www.houseoffusion.com/banners/view.cfm?bannerid=37>
>[]
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

