You can handle this by defining a transient bean CFC in your model,
populating an instance of the bean via the event context, and passing the
populated bean to your service method. Your transient bean must have setter
methods for each form field (either explicit methods or implicit setters via
CF9 property declarations).
Controller code in CFScript syntax:
var transientBean =
CreateObject("component","app.model.transientBean").init();
arguments.event.makeEventBean(transientBean,
"field1,field2,field3,field4,field5,field6,field7,field8,field9,field10");
beans.someService.serviceMethod(transientBean);
The field list may be omitted (it defaults to all fields in the event
context) but I prefer listing them explicitly as a security measure to
prevent unintended setters from being called.
Hope that helps,
-- Dennis
On Tue, Feb 16, 2010 at 4:16 PM, Preserved Killick <[email protected]>wrote:
> Is this correct?
> A form with 10 fields is submitted.
> Modelglue.xml event handler broadcasts "dumpdata" with corresponding
> controller that calls controller.cfc
>
> Controller.cfc asks my model to dump the data.
>
> Now..do I need to pass each form field to the model via the controller
> as a var?
> As in:
> <cfset var field1 = arguments.event.getValue("field1") />
> <cfset var field2 = arguments.event.getValue("field2") />
> <cfset var field3 = arguments.event.getValue("field3") />
>
> And then, in my models function each is named as an argument?
> <cfargument name="field1" type="string" />
> <cfargument name="field2" type="string" />
> <cfargument name="field3" type="string" />
>
> With a large form, this seems very tedious. Is there a shortcut?
>
>
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en