> I guess I’m not clear on why you wouldn’t do it that way. (scope hunting)
Well, there’s nothing inherently wrong with CF’s behavior of scope hunting. What is frowned upon is using the form or url scopes directly inside of a ColdBox. The rc is how you access those values in ColdBox.
> It looks like that is how one sets the value within the RC, based on the function name and examples.
There’s nothing wrong with how you were setting the value back into the rc, I was talking about how you were referencing some_field directly from the form scope.
> rc.some_field = event.getTrimValue( ‘some_field’ );
Yes, that will work. It’s one of the options I suggested in my first reply.
> directly after getting the eventCollection,
Again, rc is a struct and passed by reference so it doesn’t matter when you do it. You also don’t need to do rc = event.getCollection. It’s in the arguments scope already so long as your on Coldbox 3+
> That works, but I’m not sure if I’m still “scope hunting” with that method.
No, not at all. event.getTrimvalue() acts directly on the internal request collection and rc.some_field is also dealing directly with the rc as a struct.
Note that rc.foo is the same as event.getValue( ‘foo’ ). and trim( rc.foo ) is the same as event.getTrimValue( 'foo ’ ). Those helper methods just act on the internal rc struct.
> That code throws an CF error.
Nope, works great for me. Here’s a trycf.com example of that exact snippet running perfectly.
> Is there a working example of how to “process” a form submission with coldbox?
I don’t understand what you mean. You don’t need to do anything to “process” a form submission in ColdBox. The form scope will simply be available via the request collection (rc) which is always the case and you simply use the variables like you normally would. There’s nothing else to it. If by “process” you mean you want to loop over each of the submitted fields and do something to them (like trim them) then just loop like you normally would in CFML. rc is just a struct so any flavor of looping mechanism that supports collections will work just fine. The code I provided does just that.