I have a simple form that edits page content, I do this:
index.cfm
<cfcase value="getEditPage">
<cfset PageRecord = application.Reactor.createRecord("Pages")>
<cfset PageRecord.setPageID(#vars.PageID#)>
<cfset PageRecord.load()>
<cfinclude template="frmPage.cfm" />
</cfcase>
frmPage:
<cfform
action="index.cfm?event=actSavePage&pageid=#PageRecord.getPageID()#">
...
<cftextarea name="pagecontent" value="#PageRecord.getPageContent()#">
...
</cfform>
Question? Since the frmPage doesn't post back to itself, how do I save
the page record? Do I have to create the page record again and then save
like below or is there a better way?
index.cfm
<cfcase value="actSavePage">
<!--- Same 3 lines of code as in getEditPage case value --->
<cfset PageRecord = application.Reactor.createRecord("Pages")>
<cfset PageRecord.setPageID(#vars.PageID#)>
<cfset PageRecord.load()>
<cfset
PageRecord.setPageContent(preservesinglequotes(vars.pagecontent))>
<cfset
PageRecord.setDateLastModified('#DateFormat(Now(),"mm/dd/yyyy")#
#TimeFormat(Now(), "hh:ss tt")#')>
<cfset PageRecord.save()>
<cflocation url="index.cfm?event=main" />
</cfcase>
Thanks!
Marcus Cox