views:

23

answers:

1

I have two models Posts and Tags Posts HasManyBelongsToMany Tags

lets say a post 1 has tags world, news, paper

now in the joining table i wanna remove the relation between tag paper with the post 1. but the tag paper should be there in the tags table.

just in the joining table the relation should be deleted.

how to do this in CakePHP ?

+2  A: 

When you do any HABTM operation other than adding a new one, Cake deletes and recreates the associated join table rows. All you have to do is get the record, remove the tag and save the record again.

In the view I write the tags into one form input field. When the record is saved, I process the value of this field to extract the tags (explode by comma or space or whatever) then save the tags.

There is a good guide here: http://mrphp.com.au/code/working-habtm-form-data-cakephp

Leo