Element TEMPLATE is undefined in FORM
i am a newbie to coldfusion. i'm using switchbox to create a simple app that allows me to add and save html templates.
I created another app to add and save events which was successful but the templates one eludes me.
my database is the 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 is my 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 as a
inner join template_status as 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 from acme5425.template where 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#'
where template_id = #form.template_id#
</cfquery>
Your changes have been saved. <a href="index.cfm?fuseaction=home.templates">Return</a> to template listing.
</cfcase>
<cfcase value="addtemplate">
Adding a 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 will be the value returned if someone types in "circuitname.", omitting the actual fuseaction request--->
</cfcase>
<cfdefaultcase>
<!---This will just display an error message and is useful in catching typos of fuseaction names while developing--->
<cfoutput>This is the cfdefaultcase tag. I received a fuseaction called "#attributes.fuseaction#" and I don't know what to do with it.</cfoutput>
</cfdefaultcase>
</cfswitch>
