Array and Struct notation in Forms

This may be a CF question and not a CB question, but I can't seem to
find any information on it on Google or in the CB docs.

Having a relationship of many products to 1 order...

Is there a way to setup my form fields so that when I use
populateModel(rc.order), that it will also populate
rc.order.setProducts(array of product model properties) like you use
with "nested_attributes" in Ruby on Rails?

I know I can loop through my form fields and build an array of my
product properties for each product in my form submitted and then set
those using the setProducts() method in my Orders model, but I didn't
know if I was making extra work for myself over just setting the names
on my form fields to a certain notation so that populateModel() works
in this manner.

Any help would be greatly appreciated.

Thanks

Erick

Erick, this has been requested for a while now and I would love user input in how to add this functionality?

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

I have done something like this a while back using Brian Kotek’s form utilities. So the naming of the form fields determines the datatype, and then go from there. My implimentation wasn’t generic, but it could be a good starting point.

  • sent by a little green robot powered device

Yeah, I saw Brian’s utility and that might be a good start for jumping off.
I am personally used to the way Rails does nested attributes but honestly if we just used CF notation, it would be something that is familiar to everyone. That way if the code sees a form variable parentObj.childArray[1].childObjProperty (basically if it sees dots, and braces or even braces with quotes in them), it would assume a structure or an array and parse it out.

I think the biggest key would be allowing populateModel() to take that input structure and assuming the form field names are the same, it would populate the entire relationship across all child objects it finds that matches.

Since I can’t do that now, I’ve got no problem programatically setting all my child properties, but that might be a good CB 4.0 addition that would speed up development even more. I’d love to help make that happen when you get there, if you need it.

Thanks

Erick Wilson
AngelsEye, Inc
800-690-3740 - Ext. 101
800-690-2089 - Fax
ewilson@angelseyeinc.com
www.angelseyeinc.com

“If you don’t know where you are going, any road will take you there.” – Lewis Carroll, Alice in Wonderland

Yes, please, I would love community help here

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano