在提交我的ColdFusion表单时,我想将输入的值保存到Serialized JSON中。
以下是我之前提问的一个例子。下面的代码位于我的action.cfm页面中,该页面被设置为我的表单的操作页面。
<cfset formCopy = Duplicate(form)>
<!--- We have to duplicate the struct so that we can safely modify a copy without affecting the original --->
<cfset DeleteItems = "fieldnames,gobtn">
<cfloop list="#deleteItems#" index="df">
<cfset formCopy = StructDelete(formCopy,df)>
</cfloop>
<cfset ForDBInsert = SerializeJSON(formCopy)>
<!--- ForDBInsert now contains a JSON serialized copy of your data. You can insert it into
the database as such, and call it back later. --->
如果我将所有内容都删除,只留下副本(表单),我的页面仍然会出错。
问题:我是否需要通过名称或“表格”来引用我的表单?
答案 0 :(得分:4)
我的网页仍有错误。
这并没有告诉我们多少。您需要发布实际的错误消息。但是,我怀疑是因为您错误地使用StructDelete
。 StructDelete
返回boolean
值,而不是结构。通过将结果保存到“formCopy”,您将使用简单的布尔值覆盖结构。下次将其传递给StructDelete
时,会发生错误,因为“formCopy”不再是结构。