Created
February 13, 2012 22:49
-
-
Save chrisdpeters/1821222 to your computer and use it in GitHub Desktop.
Improving the Tutorial (Again): Including Partials to DRY Up Forms in CFWheels
This file contains 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
<cfparam name="user"> | |
<cfoutput> | |
#textField(objectName="user", property="name", label="Name")# | |
#textField(objectName="user", property="email", label="Email")# | |
#passwordField(objectName="user", property="password", label="Password")# | |
</cfoutput> |
This file contains 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
<cfparam name="user"> | |
<cfoutput> | |
<h1>Create a New User</h1> | |
<cfif flashKeyExists("success")> | |
<p class="success">#flash("success")#</p> | |
</cfif> | |
#startFormTag(action="create")# | |
#includePartial("form")# | |
<div> | |
#submitTag(value="Create")# | |
</div> | |
#endFormTag()# | |
</cfoutput> |
This file contains 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
<cfparam name="user"> | |
<cfoutput> | |
<h1>Edit User</h1> | |
<cfif flashKeyExists("success")> | |
<p class="success">#flash("success")#</p> | |
</cfif> | |
#startFormTag(action="update")# | |
#includePartial(user)# | |
<div> | |
#hiddenField(objectName="user", property="id")# | |
#submitTag()# | |
</div> | |
#endFormTag()# | |
</cfoutput> |
This file contains 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
<cffunction name="add"> | |
<cfset user = model("user").new()> | |
</cffunction> | |
<cffunction name="edit"> | |
<cfset user = model("user").findByKey(params.key)> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment