CakePHP - 如何将评论表格与当前帖子绑定?

时间:2010-11-07 21:27:50

标签: cakephp

我的网站包含评论表单Post。如何在id评论控制器方法中收到add()帖子? THX!

1 个答案:

答案 0 :(得分:2)

如果模型绑定正确(Post hasMany Comment,Comment belongsTo Post),你可以这样做:

/views/comments/add.ctp或/views/posts/view.php:

<?php echo $this->Form->input('post_id', array('type' => 'hidden', 'value' => $post['Post']['id'])); ?>