[ColdBox-3.7.0] Not Preserving Form

When I submit and it returns errors, the form is not being preserved. I originally assumed that form preservation was built in to Coldbox and automatic however I have found this not to be the case. Or maybe I am wrong and there is a bug or configuration issue. Any idea whats going wrong here?

Example and code:

Before form submission:

After submission:



There is nothing built in, however, if you run the original event in the same request, and all the values are still in the request collection, AND you built your form to populate itself from the rc, it will work. Additionally, if you redirect back to your form as a second request you can use the persist params to setNextEvent() to store certain fields in flash RAM.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks Brad.

Do you know of any coldbox applications on github (examples or otherwise) that are doing this or is it common/conventional for coldbox apps to not preserve forms?

I don’t know of any framework that preserves forms for you. (I mean, how would the framework know what you want?) Every (good) developer I know writes that into his application though. That’s why ColdBox makes it so easy to do with persisting via Flash RAM.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Yeah, not to compare apples to oranges but cfwheels built-in orm provided this by default. Since that is the only framework I have experience with I am just trying to translate my knowledge from that world. I also want to see how other frameworks do things and what I should and should not expect. However so far there are tons of parallels and the transition is smoothing out, just hitting a few snags here and there.

To expand slightly on Brad’s comment, the form is independent of the framework, so the framework can’t possibly know how to populate data into a form. That’s up to the coder to do, and it’s dead simple:

// example


Except in ColdBox you would do something like

<input name=“firstName” value="#event.getValue(“firstName”,"");#" />

Because ColdBox merges the url etc into the Request Context, then you would just use the above to see if it was passed via the form, if not then it will return an empty string.

That is as simple as your going to get.

Oh, right. I forgot that rc in ColdBox is only in the controllers. Thanks, Andrew.

Actually RC and PRC is available almost everywhere, it is how you use it, that matters.

Andrew, you’re the man! Works exactly how I wanted!

Thanks :slight_smile:

And this even takes it to the next level:

That is wrong, here is what you are doing… First your going to see if it exists in the rc scope, which is what was submitted if it doesn’t exist then it ends up using what is stored in the entity, which I am assuming you default to an empty string.

Personally, I would just leave it as


Saves running and returning something that you are going to set to an empty string any way. Unless there is real benefits from that way, then by all means, but personally I wouldn’t bother and stick with the code above this paragraph.


ColdBox also offer HTMLHelper Plugin which generates form based on provided Orm-Entity


Documentation is missing the information about “entityFields” method but you can look the code /system/plugins/HTMLHelper.cfc


Hmm, not sure how that fits in here Sana if you have an example of how that works. But it seems like a lot of code to display a form variable and if it wasn’t submitted display an empty string…