Created
June 16, 2010 03:17
-
-
Save rip747/440107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Controller save method | |
====================== | |
<cffunction name="save"> | |
<cfif len(params.chapter.chapterid)> | |
<cfset chapter = model("chapter").findByKey(params.chapter.chapterid)> | |
<cfset chapter.setproperties(params.chapter)> | |
<cfset _page.title = _pageTitle("edit")> | |
<cfelse> | |
<cfset chapter = model("chapter").new(params.chapter)> | |
<cfset _page.title = _pageTitle("new")> | |
</cfif> | |
<cfif !chapter.valid()> | |
<cfset flashInsert(error="Errors")> | |
<cfset renderPage(template="addedit")> | |
<cfelse> | |
<cfif params.command eq "preview"> | |
<cfset _page.title = _pageTitle("preview")> | |
<cfset renderPage(template="preview")> | |
<cfelseif params.command eq "makechanges"> | |
<cfset renderPage(template="addedit")> | |
<cfelse> | |
<cfset chapter.save()> | |
<cfset redirectTo(action="index")> | |
<cfreturn> | |
</cfif> | |
</cfif> | |
</cffunction> | |
Add/Edit Page Buttons | |
======================== | |
<dl class="make_changes_buttons"> | |
<dd>#buttonTag(content="Preview", value="preview", name="command")#</dd> | |
<dd>#buttonTag(content="Save", value="save", name="command")#</dd> | |
</dl> | |
Preview Page Hidden Form Creation and Buttons | |
============================================= | |
#startFormTag(action="save")# | |
<cfloop collection="#chapter.properties()#" item="property"> | |
#hiddenField(objectName="chapter", property="#property#")# | |
</cfloop> | |
<dl class="make_changes_buttons"> | |
<dd>#buttonTag(content="<< Make Changes", value="makechanges", name="command")#</dd> | |
<dd>#buttonTag(content="Publish >>", value="save", name="command")#</dd> | |
</dl> | |
#endFormTag()# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment