Model hasAndBelongsToMany(HABTM)はpostに設定します。 models > post.php class Post extends AppModel { public $name = 'Post'; public $hasAndBelongsToMany = array( 'Tag' => array( 'className' => 'Tag', 'joinTable' => 'posts_tags', 'foreignKey' => 'post_id', 'associationForeignKey' => 'tag_id', 'fields' => array('id','name'), 'unique' => true ), ); } models > tag.php class Tag extends AppModel { public $name
![CakePHPのhasAndBelongsToMany(HABTM)をチェックボックスで関連付ける](https://cdn-ak-scissors.b.st-hatena.com/image/square/4a3a2973dd7939605d3daca5f8858bbc32b103b0/height=288;version=1;width=512/https%3A%2F%2Fwww.webopixel.net%2Fimg%2Fog.png)