Should the Controller be used to extract form data from a dynamic form.

I have a dynamic form… I was wondering if it is considered a good idea to extract the form data within your controller layer?

for(local.i=1 ; local.i <= local.suppliers.recordCount; local.i++){
local.suppliercode = local.suppliers.suppliercode[local.i];
local.formFieldName = ‘local_’ & local.suppliercode;
local.myformvalue = form[local.formFieldName];


Or should this extraction/parse logic go elsewhere?


Personally I would wrap it up in a function in a service layer or some plugin maybe, nothing wrong with calling it there in the controller, just maybe better if it may be something you will or may use again if it is written as such to begin with.

My rule is, if there is a chance it could be re-used then refactor it to be re-usable.

I see… I didnt think there was anything wrong with doing it this way… But yes it makes sense to abstract it away in its own method so it can be reused.

something like parseFormDataForUpdate

Thanks for your help!

What you could also do, is use interception points to do this automatically as well.

I don’t see why not, but use the rc scope, not the form scope. rc is the proper way to access form and URL variables in ColdBox.

Also, there is a really nifty tool that helps with dynamic form fields called Form Utilities. Basically, you name your form fields as though they are structs or arrays, and this plugin will parse your form fields and actually turn the data into structs and arrays on the server side. Crazy handy for looping over unknown amounts of elements.

Here’s a ColdBox Connection I did once on setting it up:

And here’s the sample code to get it working:



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

Thanks everyone for you tips!