> You are not looping over the form scope here, you are looping > over the form variable form.fieldnames. The presence of this > variable in the debug output makes me believe that this list is > actually created by the browser and submitted together with all > the other formfields. Which would also explain why this variable > is not updated when adding fields to the form scope/structure > serverside.
The variable FORM.FIELDNAMES doesn't come from the browser; it's created by CF in any script to which form data has been submitted. It's been around in CF since at least version 2, and it allows the construction of generalized form data handlers, since you can loop through the list of all form data sent from the browser with it. Of course, in version 4.x and up, you're probably better off looping over the Form structure. I suspect that FORM.FIELDNAMES has been kept around with its behavior unchanged just for backward compatibility. One interesting thing about FORM.FIELDNAMES is that, if you have multiple form fields with the same name, the name is listed multiple times in FORM.FIELDNAMES, which reflects how the browser actually sends the data. So, if you use it to write a generalized form data handler, you have to take that into account. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ phone: (202) 797-5496 fax: (202) 797-5444 -----Original Message----- From: Jochem van Dieten To: CF-Talk Sent: 11/13/01 12:15 PM Subject: Re: Are forms really structures? Kola Oyedeji wrote: > > AFAIK the form scope is available as a structure: > > If i have a form with the following field: > > <form name="myform" action="test3.cfm" method="post" > > <input type="text" name="name" value="kola" > > <input type="Submit" > > </form> > > and on the action page create an additional form field, > Then loop over the field names with the follwing code, only the real form > field submmited by the form is displayed. > > <cfset form.fake = "hello" > > <cfloop list="#fieldnames#" index="current"> > <br><cfoutput>#current#</cfoutput> > </cfloop> > If I then loop over the form as a structure: > So the question is, is this a feature or a bug? Feature. But maybe one that requires a note at livedocs.allaire.com Jochem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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

