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:

<!--- In the controller --->
<cfif toilet.flush()>
<cfset flashInsert(success="Whoooooooosh!")>
<cfset redirectTo(action="lockerRoom")>
</cfif>
view raw OldToilets.cfc hosted with ❤ by GitHub

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):

<!--- In the controller --->
<cfif toilet.flush()>
<cfset redirectTo(action="lockerRoom", success="Whoooooooosh!")>
</cfif>
view raw NewToilets.cfc hosted with ❤ by GitHub

Less code FTW!

About Chris Peters

With over 20 years of experience, I help plan, execute, and optimize digital experiences.

Leave a comment