【发布时间】:2013-07-24 12:39:53
【问题描述】:
我已经为发布和评论制作了控制器和模型。
我的帖子索引调用了我的添加评论视图。它工作正常,但添加评论视图会打开另一个页面。
然后,我将添加评论视图包含在一个元素中,以便直接调用我的帖子页面,但是当我单击我的 cmets 添加视图的提交按钮时,它不会保存任何内容。
当我查看提交按钮显示的链接时,它指向我的帖子索引视图。
如何让它发挥作用?
这是我的评论元素的代码
div class="comments form">
<?php echo $this->Form->create('Comment'); ?>
<fieldset>
<legend><?php echo __('Add Comment'); ?></legend>
<?php
$this->request->data['Comment']['user_id'] = $current_user['id'];
$this->request->data['Comment']['post_id'] = $post_id;
echo $this->Form->input('post_id', array('type' => 'hidden'));
echo $this->Form->input('user_id', array('type' => 'hidden'));
echo $this->Form->input('content');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
这里是索引帖子视图调用该元素的部分代码
<div class="element">
<?php echo $this->element('add_comment', array('post_id' => $post['Post']['id'])); ?>
</div>
我必须补充一点,这个 div 类元素位于可点击的 div 中。但是对于我在视图中的其他按钮,单击效果很好。
【问题讨论】: