Reputation: 3308
How can you disable the sameformfieldsasarray
when you have an Application.cfm
file?
I'm porting a legacy application from ColdFusion 9 to ColdFusion 10. The site uses an old school Application.cfm
file.
I see that 10 added a new setting (this.sameformfieldsasarray
) that you can enable that will combine form variables into an array when there is more than one of them. This is supposed to be off by default, but unfortunately it's "on" for the fresh installation I just set up.
I can't set this.sameformfieldsasarray
false because we've got Application.cfm
instead of Application.cfc
, and I can't find anything in the admin or documentation.
The code is run from a fresh install of CF10 on Ubuntu 12.04 x64. @Adam verified that the sample code worked on Windows Server 2003 x64.
Code: https://gist.github.com/2931343
Screenshot of sample submit: https://i.sstatic.net/mNRsY.jpg
Screenshot of server scope: https://i.sstatic.net/WWHih.jpg
Bug report submitted: https://bugbase.adobe.com/index.cfm?event=bug&id=3214734
Upvotes: 4
Views: 562
Reputation: 6884
I realize this post is nearly a dozen years old, but it came up in a search today about this feature, and I wanted to propose an answer that I don't see anyone else having offered--and it seems the exact resolution to the original problem, albeit surely too late for the OP/Zack. :-)
He's said:
I can't set
this.sameformfieldsasarray
false because we've gotApplication.cfm
instead ofApplication.cfc
, and I can't find anything in the admin or documentation.
It's indeed true that sadly, most docs and resources mentioning this sameformfieldsasarray
feature (and other features that can be set in the this
scope of an application.cfc
) tend to not mention how nearly all of them can be set simply as attributes of cfapplication
as well.
<cfapplication sameformfieldsasarray="false">
(or true, if desired)
But yep, there was indeed a problem originally that it defaulted to true, which was fixed in CF10 update 1. The same problem happened again with CF2018 update 11 and CF2021 update 1--but the default reverted to true again in CF2018 update 12 and CF2021 update 2.
Upvotes: 1
Reputation: 1792
This issue is now resolved in ColdFusion 10 Update 1 which was released on 31st August 2012.
Applying the update should resolve the issue and allow workarounds such as the one suggested by Mark A Kruger to be removed.
Upvotes: 2
Reputation: 7193
I'm not sure about this one. CF 10 is so new that you are probably the first person to ask this question in public (ha). But perhaps you could do the following in your application.cfm.
<cfloop collection="#form#" item="fitem">
<cfif isArray(form[fitem])>
<cfset form[fitem] = arraytolist(form[fitem])/>
</cfif>
</cfloop>
That would set things right I suspect.
Upvotes: 3