Thanks to all. This is what I was looking for. Have to give great KUDOS to those that follow this group. The support is great.
Thanks again, Cliff On Sep 10, 8:04 am, Dan Wilson <[email protected]> wrote: > Zac and Matt hit upon the core of the issue which is: > > You need to get all the values out of the event that match your dynamic > field pattern ( CourseTitle and an Underscore ) > Then, validate then items and save them. > > I wrapped up all of this into separate objects, myself, just to keep the > controller clean. What happens is in the controller, I pass all the event > values into the StatsInputBean. When I do, the bean filters out the fields > that do not match my dynamic field pattern (which is 3 values delimited by a > colon (x:y:z). Then I validate it, and save it. > > Controller Method: > > <cffunction name="handleStatsInput" output="false" access="public" > returntype="void" hint="I handle submitted stats"> > <cfargument name="event" type="any"> > <cfset var local = {} /> > <cfset arguments.event.copyToScope( local, "CurrentMember,UserMsg" ) /> > <!--- Create the bean I need ---> > * <cfset local.StatsInputBean = > beans.simpleInstanceFactory("StatsInputBean") />* > <!--- stuff it with the event data ---> > * <cfset local.StatsInputBean.setStatsInputData( arguments.event.getAll() ) > />* > <cfset local.StatsInputBean.setMemberID( local.CurrentMember.getMemberID() > ) /> > <!--- if it validates, then process the data --> > * <cfif local.StatsInputBean.validate( local.UserMsg ) IS true>* > * <cfset beans.StatsInputProcessor.processInput( local.StatsInputBean ) />* > <cfset arguments.event.addResult( "Success" ) /> > <cfelse> > <cfset arguments.event.addResult( "Failure" ) /> > </cfif> > </cffunction> > > That keeps the controller nice and tidy. Now, here is the definition for: > > StatsInputBean.cfc http://pastebin.com/HY7FkyZF > StatsInputProcessor.cfchttp://pastebin.com/qUJuGrPD > > On Sat, Sep 10, 2011 at 1:40 AM, Matt Quackenbush <[email protected]>wrote: > > > > > > > > > > > form.fieldNames will give you a list of all the form fields. But that > > isn't really appropriate in the context of an MG controller. Instead you > > might do something like so... > > > var tmp = ""; > > var key = ""; > > for ( key IN event.getAllValues() ) > > { > > if ( reFindNoCase("CourseTitle_[\d]+",key) ) > > { > > // it matches; do something > > } > > } > > > I don't know exactly what you're trying to do, so there might be a > > different/better way to do it, but that will hopefully get you on your way. > > > On Fri, Sep 9, 2011 at 8:58 PM, Zac Spitzer <[email protected]> wrote: > > >> structKeyList(form) will give you a list of all the form fields passed > > >> you can reference any form field dynamically using struct notation > > >> ie form["whatsit#i#"] etc > > >> this works with all scopes and with queries you can even access > >> rows using this syntax > > >> q_roles["role"][3] which means row number three, column role etc > > >> On Sat, Sep 10, 2011 at 7:47 AM, Clifford Moon > >> <[email protected]>wrote: > > >>> Greetings, > > >>> I'm having to custom build a form that has is dynamically sized and > >>> I'm having to create the field names, differentiating them by a value > >>> at the end of the form field .. ie CourseTitle_1, CourseTitle_2, etc. > >>> The value at the end is the ID of the Record that will need to be > >>> updated. Once I submit this form, how can I evaluate those fieldnames > >>> and get the values from them within the controller. I know what those > >>> values being appended to the end of the form field name are because > >>> they are submitted as a hidden list within the form. > > >>> Any help is greatly appreciated. > > >>> Thanks, > > >>> Cliff > > >>> -- > >>> 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 > > >> -- > >> Zac Spitzer > >> Solution Architect / Director > >> Ennoble Consultancy Australia > >>http://www.ennoble.com.au > >>http://zacster.blogspot.com > >> +61 405 847 168 > > >> -- > >> 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 > > > -- > > 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 > > -- > Plutarch - "The mind is not a vessel to be filled but a fire to be kindled." -- 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
