Element TEMPLATE is undefined in FORM
i newbie coldfusion. i'm using switchbox create simple app allows me add , save html templates.
i created app add , save events successful templates 1 eludes me.
my database following:
create table [acme5425].[template](
[template_id] [int] identity(1,1) not null,
[name] [varchar](100) collate sql_latin1_general_cp1_ci_as null constraint [df__template__name__6fe99f9f]
default (null),
[notes] [text] collate sql_latin1_general_cp1_ci_as null,
[template_html] [text] collate sql_latin1_general_cp1_ci_as null,
[template_status_id] [int] null,
[created] [datetime] null constraint [df_template_created] default (getdate()),
constraint [pk_template] primary key clustered
here application code
<!--- ///////////////////////////////start of template section d coded 5/29/09 ////////////////////////////// --->
<cfcase value="templates">
<cfquery name="xxx" datasource="#dsn#" username="#dbuser#" password="#dbpassword#">
select a.name,a.notes,a.template_html,b.template_status_id,a.created,template_id
from template
inner join template_status b on a.template_status_id = b.template_status_id
</cfquery>
<table width="450">
<tr>
<td>template title</td>
<td>notes</td>
<td>html content</td>
<td>status</td>
<td>date created</td>
<td colspan="2"></td>
</tr>
<cfoutput query="xxx">
<tr>
<td>#name#</td>
<td>#notes#</td>
<td>#template_html#</td>
<td>#template_status_id#</td>
<td>#created#</td>
<td><a href="index.cfm?fuseaction=home.edit_template&template_id=#template_id#">edit tempplate</a></td>
<td><a href="index.cfm?fuseaction=home.delete_template&template_id=#template_id#">delete template</td>
</tr>
</cfoutput>
</table>
<a href="index.cfm?fuseaction=home.addtemplate">add template</a>
</cfcase>
<cfcase value="delete_template">
<cfquery name="xxx" datasource="#dsn#" username="#dbuser#" password="#dbpassword#">
delete acme5425.template template_id = #url.template_id#
</cfquery>
<cflocation url="index.cfm?fuseaction=home.template">
</cfcase>
<cfcase value="edit_template">
<cfquery name="xxx" datasource="#dsn#" username="#dbuser#" password="#dbpassword#">
select a.name,a.notes,a.template_html,template_id
from template
where template_id = #url.event_id#
</cfquery>
<form name="zzz" action="index.cfm?fuseaction=home.save_edited_template" method="post">
<input type="text" name="name" value="<cfoutput>#xxx.name#</cfoutput>">
<input type="text" name="notes" value="<cfoutput>#xxx.notes#</cfoutput>">
<input type="text" name="template_html" value="<cfoutput>#xxx.template_html#</cfoutput>">
<input type="hidden" name="template_id" value="<cfoutput>#url.template_id#</cfoutput>">
<input type="submit" value="save changes">
</form>
</cfcase>
<cfcase value="save_edited_template">
<cfquery name="xxx" datasource="#dsn#" username="#dbuser#" password="#dbpassword#">
update acme5425.template
set notes = '#form.template#'
template_id = #form.template_id#
</cfquery>
changes have been saved. <a href="index.cfm?fuseaction=home.templates">return</a> template listing.
</cfcase>
<cfcase value="addtemplate">
adding template
<table width="450" border="1">
<tr>
<td>template title</td>
<td>notes</td>
<td>html content</td>
<td colspan="2"></td>
</tr>
<tr>
<form name="new_template" action="index.cfm?fuseaction=home.save_new_template" method="post">
<input type="text" name="name">
<input type="text" name="notes">
<input type="text" name="template_html">
<input type="submit" value="save new template">
</form>
</tr>
</cfcase>
</table>
<cfcase value="save_new_template">
<cfquery name="xxx" datasource="#dsn#" username="#dbuser#" password="#dbpassword#">
insert acme5425.template("names","notes","template_html",template_status_id)
values ('#form.template#')
</cfquery>
<cflocation url="index.cfm?fuseaction=home.template">
<!--- /////////////////////// end of template section d coded 5/29/09 /////////////////////////////////--->
<table width="450">
<tr>
<td>template 1</td>
<td>edit</td>
<td>delete</td>
</tr>
<tr>
<td>template 2</td>
<td>edit</td>
<td>delete</td>
</tr>
<tr>
<td>template 3</td>
<td>edit</td>
<td>delete</td>
</tr>
</table>
add template
</cfcase>
<cfcase value="fusebox.defaultfuseaction">
<!---this value returned if types in "circuitname.", omitting actual fuseaction request--->
</cfcase>
<cfdefaultcase>
<!---this display error message , useful in catching typos of fuseaction names while developing--->
<cfoutput>this cfdefaultcase tag. received fuseaction called "#attributes.fuseaction#" , don't know it.</cfoutput>
</cfdefaultcase>
</cfswitch>
i browsed through code, and:
1. saw form fields named template_id , template_html, nothing called template.
2. saw no if/else logic regarding whether form had been submitted or not.
More discussions in ColdFusion
adobe
Comments
Post a Comment