Add to the Flash with redirectTo() in CFWheels 1.1
October 1, 2010 · Chris Peters
In CFWheels 1.1 (now in beta), you can now add messages to the Flash from redirectTo() instead of needing to call flashInsert() separately.
Another small enhancement added to the upcoming CFWheels 1.1 (now in beta). You can now add messages to the Flash from redirectTo()
instead of needing to call flashInsert()
separately.
Consider this old, weathered code from CFWheels 1.0.x:
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
<!--- In the controller ---> | |
<cfif toilet.flush()> | |
<cfset flashInsert(success="Whoooooooosh!")> | |
<cfset redirectTo(action="lockerRoom")> | |
</cfif> |
Now this can be combined into the redirectTo()
call in 1.1 by passing an argument called success
(or any Flash key that we want):
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
<!--- In the controller ---> | |
<cfif toilet.flush()> | |
<cfset redirectTo(action="lockerRoom", success="Whoooooooosh!")> | |
</cfif> |
Less code FTW!