> I didn't think this through, however, because there is no way to place
> the default value of each of these fields in the actual form, which is
> located outside of the loop, is there? In other words, the following
> code will not work...

> <input type="text" name="#myformfield#" value="#myformfield.value#>

> ..unless I place it in the loop. And since there is so much other
> formatting going on in the form, there really is no way to do that. So
> now I'm back to manually checking the existence of each key.
> (Copy/Paste, Copy/Paste) Is there a more elegant way?

Oh there are a number of ways this could be done ...

One easy way to do this is to create a 2nd structure containing all of the
default values for the form. As you validate the form, remove any fields
which don't pass the form validation from the form scope, then append the
form structure to your default values structure and use the default values
structure to populate the form... i.e.

<cfscript>
        stDefaults = structNew();
        stDefaults.x = "blah";
        stDefault.y = "hello world";
</cfscript>

perform validation here...

<cfset temp = StructAppend(defaults,form,true)>

<cfoutput><form ...>

<cfloop item="x" collection="#stDefaults#">
<input type="text" name="#x#" value="#stDefaults[x]#">
</cfloop>

.. or something to that effect...

If you really wanted to get creative, you could store each input items
varying properties like input type, size, etc. in a structure and then store
each of those structures in a "form" structure and loop through it to
determine what form elements to display and what values to place in each
element... Once you had the structure of the form set up the way you want
it, you could serialize the structure into a wddx packet which you could
store in a file and then retrieve once during initialization of the
application and store in a persistent scope like the application scope...
But then you're basically talking about creating a whole metadata schema /
sub-application.


hth


Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to