I am trying this from last three days but can not solve
problem...Please help me to find a solution to this problem.
I want to save a extra field in HABTM Join tabel.
1) tags : tag_id, tag_name .
3) blogs : id, title, body
4) entities_tags : tag_id, entity, entity_id .
I am using HABTM relation ship between Tag and Blog modal
*Blog Model*
<?php
class Blog extends AppModel {
var $name = 'Blog';
var $hasAndBelongsToMany = array(
'Tag' => array('className' => 'Tag',
'joinTable' => 'entities_tags',
'foreignKey' => 'entity_id',
'associationForeignKey' => 'tag_id',
'with' => 'EntitiesTag',
'unique' => true,
'conditions' => 'EntitiesTag.entity = 1',
),
);
}
?>
entity_id, tag_id is saving in database successfully but entity is not
saving in tabel.
I tried following solution for this in blogs_controller
1 $this->data['EntitiesTag']['entity'] = 1
2 $this->data['EntitiesTag'][0]['entity'] = 1
3 I read one tutorial
http://teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-join-table-for-habtm-models/
I tried it but not successed.
It would be gr8 for me if somebody tell how can I save this extra
field 'entity' into Join tabel entites_tags ?
Is there missing something or doing wrong?
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment