Hi All,
Could some one help me on following:
I have three two tables:
properties : id (auto-increment), title
features : id, title

Since there is many to many relationship between tables, I have third
one:

features_properties: id, feature_id, property_id

Now this is my view: add.ctp.
<?php echo $form->create('Property');?>
        <fieldset>
                <legend><?php __('Add Property');?></legend>
        <?php
                echo $form->input('title');
                echo $form->input('pfor_id');
                echo $form->input('ptype_id');
                echo $form->input('Feature',array('multiple'=>true));
        ?>
        </fieldset>
<?php echo $form->end('Submit');?>

controller:
add method:
function add() {
                if (!empty($this->data)) {
                        debug($this->data);
                        $this->Property->create();

                        if ($this->Property->save($this->data)) {


                                $this->Session->setFlash(__('The Property has 
been saved', true));
                                //$this->redirect(array('action'=>'index'));
                        } else {
                                $this->Session->setFlash(__('The Property could 
not be saved.
Please, try again.', true));
                        }
                }
                $features = $this->Property->Feature->find('list');

                $this->set(compact('features'));
        }

Property Model:
var $hasAndBelongsToMany = array(
                'Feature' => array(
                        'className' => 'Feature',
                        'joinTable' => 'features_properties',
                        'foreignKey' => 'property_id',
                        'associationForeignKey' => 'feature_id',
                        'unique' => true,
                        'conditions' => '',
                        'fields' => '',
                        'order' => '',
                        'limit' => '',
                        'offset' => '',
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
                );

Data never gets saved in joint table. Can some one help me on this
please.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to