Created
March 23, 2011 12:01
-
-
Save neokoenig/883001 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
<!---Contacts.cfc---> | |
<cffunction name="init"> | |
<cfset filters(through="getCategoryTypes", only="add,edit,update")> | |
<cfset filters(through="getCurrentContact", only="view,edit,update")> | |
<cfset verifies(only="getCurrentContact", params="key", paramsTypes="integer")> | |
</cffunction> | |
<cffunction name="add" hint="Add a New Contact"> | |
<cfset var newEmailaddress[1]=model("emailaddress").new()> | |
<cfset var newCategory[1]=model("category").new()> | |
<cfset contact=model("contact").new(emailaddresses=newEmailaddress,categories=newCategory)> | |
<cfset renderPage(action="edit")> | |
</cffunction> | |
<cffunction name="update"> | |
<cfset contact.update(params.contact)> | |
<cfif contact.hasErrors()> | |
<cfset renderPage(action="edit")> | |
<cfelse> | |
<cfset flashInsert(success="The contact was updated successfully.")> | |
<cfset redirectTo(action="view", key=contact.id)> | |
</cfif> | |
</cffunction> | |
<cffunction name="getCategoryTypes" access="private"> | |
<cfset categoryTypes=model("categoryTypes").findAll()> | |
</cffunction> | |
<cffunction name="getCurrentContact" access="private"> | |
<cfset contact=model("contact").findone(where="id=#params.key#", include="emailaddresses,categories")> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment