In your offers_controller.php, are you using $this->Offer->save() or $this->Offer->saveAll() ? (See: http://book.cakephp.org/view/1031/Saving-Your-Data to review the explanation of each).
On Feb 10, 10:58 am, "John H." <[email protected]> wrote: > Hi all, > > I am working on a project for a client and had a programmer create the > app. Funding is out so I am taking over the project myself and have > little/no knowledge of cakePHP (I have used codeIgniter instead). I > am having problems getting a multiple select to work. Can someone > help? > > The multiple select shows up on the page as directed and populates the > selects correctly, BUT everything is automatically selected and when I > submit the form (on and edit page) it does't record anything in the > Database! Since I coded all this part, I am sure I have missed > something or did something wrong. > > Here is my setup: > > I have 3 tables > offers table > fundraiser table (each offer can have multiple fundraisers it donates > too when the offer is purchased, and each cause can be attached to > multiple offers) > offers_fundraiser table (a bridge table that connects the two) > > Controller > [Offer] > function edit($id = null) > { > ...... > $fundraisers = $this->Fundraiser->find('list', array( > 'order' => array( > 'Fundraiser.name' => 'asc' > ) > )); > $selected = array_keys($fundraisers); > $this->set('options', $fundraisers); > $this->set('selected', $selected); > $this->set('offer', $offer); > > } > > [edit.ctp view] > ... > echo $form->input('fundraiser_id', array('label' => > __l('Fundraisers'),'empty' => 'Please > Select','multiple'=>'multiple','options' => $options, 'selected' => > $selected)); ?> > ... > > 3 models > [Offers model] > class Offers extends AppModel > { > var $name = 'Offers'; > var $displayField = 'name'; > var $actsAs = array( > 'Sluggable' => array( > 'label' => array( > 'name' > ) > ) , > ); > var $hasAndBelongsToMany = array( > 'Fundraiser' => array( > 'className' => 'Fundraiser', > 'joinTable' => 'offer_fundraiser', > 'foreignKey' => 'offer_id', > 'associationForeignKey' => 'fundraiser_id', > 'unique' => true, > 'conditions' => '', > 'fields' => '', > 'order' => '', > 'limit' => '', > 'offset' => '', > 'finderQuery' => '', > 'deleteQuery' => '', > 'insertQuery' => '' > ) > ); > ...... > ...... > ...... > [fundraiser model] > class Fundraiser extends AppModel > { > var $name = 'Fundraiser'; > var $displayField = 'name'; > var $actsAs = array( > 'Sluggable' => array( > 'label' => array( > 'name' > ) > ) , > ); > var $hasAndBelongsToMany = array( > 'Offer' => array( > 'className' => 'Offer', > 'joinTable' => 'offer_fundraiser', > 'foreignKey' => 'fundraiser_id', > 'associationForeignKey' => 'offer_id', > 'unique' => true, > 'conditions' => '', > 'fields' => '', > 'order' => '', > 'limit' => '', > 'offset' => '', > 'finderQuery' => '', > 'deleteQuery' => '', > 'insertQuery' => '' > ) > ); > ...... > ...... > ...... > > [Offer_Fundraiser Model] > class OfferFundraiser extends AppModel > { > var $name = 'OfferFundraiser'; > //The Associations below have been created with all possible keys, > those that are not needed can be removed > var $belongsTo = array( > 'Offer' => array( > 'className' => 'Offer', > 'foreignKey' => 'offer_id', > 'conditions' => '', > 'fields' => '', > 'order' => '', > ) , > 'Fundraiser' => array( > 'className' => 'Fundraiser', > 'foreignKey' => 'fundraiser_id', > 'conditions' => '', > 'fields' => '', > 'order' => '', > ) > ); > ....... > ....... > ....... -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
