Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)
Ben it's working the problem about save with HABTM!!! My problem was: $pharmacy = new Pharmacy(); $this->set('pharmacies', $pharmacy->find('all')); The value of the parameter 'all' wasn't working. The next works!!! $pharmacy = new Pharmacy(); $this->set('pharmacies', $pharmacy->find('all')); or $pharmacies = $this->Turn->Pharmacy->find('list'); Thank you for your help! era -- 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
Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)
Thank you very much!!! It's working and it's magic like some things in Cake... I have problems with save with HABTM, I published other post about it called "Checkbox múltiples + HABTM". Can you help with it? Thanks! era -- 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
Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)
oups, I forgive a "Categorie" replacement. You must read "PharmaciesTurn" instead of "CategoriesTurn" On 27 juil, 09:50, BenJsno wrote: > Hello, > > -- in your controller function (add or edit): > ... > $pharmacies = $this->Turn->Pharmacy->find('list'); > // FOR SELECTED CHECKBOX : (only in edit) > $options['joins'] = array( > array('table' => 'pharmacies_turns', > 'alias' => 'PharmaciesTurn', > 'type' => 'inner', > 'conditions' => array('CategoriesTurn.turn_id = Turn.id') > ), > array('table' => 'pharmacies', > 'alias' => 'Pharmacy', > 'type' => 'inner', > 'conditions' => array('PharmaciesTurn.pharmacy_id = > Pharmacy.id') > ) > ); > $options['fields'] = array('DISTINCT Turn.id'); > $options['conditions'] = array('Turn.id' => $id); > > $tmpSelected = $this->Turn->find('all', $options); > $selected = array(); > > if (!empty($tmpSelected)){ > foreach ($tmpSelected[0]['Pharmacy'] as $pharmacy){ > array_push($selected, $pharmacy['id']); > } > > } > > $this->set(compact('pharmacies','selected')); > ... > > -- in your view : > ... > echo $this->Form->input('Pharmacy', > array('label'=>false,'type'=>'select','multiple'=>'checkbox','selected'=> > $selected)); > ... > > BenJsno > > On 25 juil, 20:10, eraonline wrote: > > > > > > > > > Hello! I want to show in the view a list of checkbox of Pharmacies to > > assign to a Turn. > > > Example: > > > Turn: INPUT TEXT > > > Pharmacies: > > > CHKBOX1 > > CHKBOX2 > > CHKBOX3 > > > Can help me with this? > > Thanks! > > > eraonline -- 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
Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)
Hello, -- in your controller function (add or edit): ... $pharmacies = $this->Turn->Pharmacy->find('list'); // FOR SELECTED CHECKBOX : (only in edit) $options['joins'] = array( array('table' => 'pharmacies_turns', 'alias' => 'PharmaciesTurn', 'type' => 'inner', 'conditions' => array('CategoriesTurn.turn_id = Turn.id') ), array('table' => 'pharmacies', 'alias' => 'Pharmacy', 'type' => 'inner', 'conditions' => array('PharmaciesTurn.pharmacy_id = Pharmacy.id') ) ); $options['fields'] = array('DISTINCT Turn.id'); $options['conditions'] = array('Turn.id' => $id); $tmpSelected = $this->Turn->find('all', $options); $selected = array(); if (!empty($tmpSelected)){ foreach ($tmpSelected[0]['Pharmacy'] as $pharmacy){ array_push($selected, $pharmacy['id']); } } $this->set(compact('pharmacies','selected')); ... -- in your view : ... echo $this->Form->input('Pharmacy', array('label'=>false,'type'=>'select','multiple'=>'checkbox','selected'=> $selected)); ... BenJsno On 25 juil, 20:10, eraonline wrote: > Hello! I want to show in the view a list of checkbox of Pharmacies to > assign to a Turn. > > Example: > > Turn: INPUT TEXT > > Pharmacies: > > CHKBOX1 > CHKBOX2 > CHKBOX3 > > Can help me with this? > Thanks! > > eraonline -- 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
Multiples Checkbox and hasAndBelongsToMany (HABTM)
Hello! I want to show in the view a list of checkbox of Pharmacies to assign to a Turn. Example: Turn: INPUT TEXT Pharmacies: CHKBOX1 CHKBOX2 CHKBOX3 Can help me with this? Thanks! eraonline -- 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