Monday, June 1, 2009

Please Help, on HABTM association

Hi All,
Could some kindly help me on in following:
I have two tables: features and properties. Property may have many
Features. So I have many to many relation table features_properties
table.
properties : id, title
features : id, title
features_properties: id, property_id, feature_id.

This is my add.ctp view:
<?php
echo $form->input('title');
echo $form->input('pfor_id');
echo $form->input('ptype_id');
echo $form->input('feature',array('multiple'=>true));
?>

and add method in controller :
if (!empty($this->data)) {

if (empty($this->data)) {
$this->data = $this->Property->read(null, $id);
}
$features = $this->Property->Feature->find('list');
$this->set(compact('features'));


and model:
var $hasMany = array(
'Feature' => array(
'className' => 'Feature',
'foreignKey' => 'id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)

why property_id and feature_id are not being saved in joint table?
Please help

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: