Ok I have done this but it ends up more complicated than first thought. First thing I found was foreach $i++ was wrong since your loop is made of the id of the items not a regular count.
I have a simple list of Languages a user can select years with. Quick example: You must do your find->all( //get all of your Languages); now edit that list so instead of the standard 0, 1, 2 array you number them based on the id so you get 6,10,12,15 like the example so when you foreach you spit out the id. English [ id 6] <= hidden Language.Language.6.language_id and just make a Label spit out the name |dropdown years| <= give year select same array id Language.Language.6.year_id Spanish [ id 10] |dropdown years| French [ id 12] |dropdown years| German [ id 15] |dropdown years| When you save you end up with an array of (debug your data before save and exit(); so you can just keep testing the same thing over ) Language => array( Language => array( [6]=> array( [year_id] => 2), [10]=> array( [year_id] =>), [12]=> array( [year_id] => 5), [15]=> array( [year_id] => 1), )); You also have to run this thru a foreach or other way to remove all Languages that have nothing selected if you allow an option to not be selected before saving. Then you're left with an array of just selected options. That's it. Mine is more indepth than this with validating selects per options. One thing I do hate is that a user can make changes when ever you have to deleteAll previous selections and then save the new array. A user might just update English from 2 -5 years to 5 - 10 years keeping the rest the same but to check each record for changes, additions, deletions, seemed like way to much. Im sure there may be other ways to get this done but it works for me. Good luck -----Original Message----- From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of Maurits van der Schee Sent: Thursday, February 10, 2011 7:15 AM To: cake-php@googlegroups.com Subject: Re: HABTM w/ Multiple Select type Field and saveAll() on multiple records. Hi, If you use InnoDB tables in MySQL you can use a transaction: http://deadlytechnology.com/web-development-tips/jquery-cakephp-tips/ This lets you define a for loop and do multiple save() calls on different models and then commit if all went well or rollback on failure. Regards, Maurits On 02/09/2011 11:10 PM, OldWest wrote: > > I wanted to know if you have much experience with saveAll() w/ HABTM on > a multiple select field? > > I can get the Zips populated from the plans_zips table (with the below), > but I cannot get the zips to save in the HABTM plans_zips table.. > > ... > *<?php echo $this->Form->input('"$i".Zip', array(* > *'type' => 'select',* > *'multiple' => 'true',* > *'label' => 'Select the Zips'* > *));* > *?>* > ... > > The $i represents the for loop I am using for the adding of multiple > records. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more > options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php