【发布时间】:2011-01-31 17:20:12
【问题描述】:
我有一个新闻控制器,每个新闻项都有一个“查看”操作。在每个新闻项目的“查看”操作中,我想包含另一个视图,即 cmets 控制器的“添加”操作。 基本上,我需要在每个新闻项目的页面上添加一个表格来添加 cmets。 我有这两种观点,但我无法将它们联系起来。我尝试使用元素,但它似乎没有呈现添加评论视图的视图。
我该怎么办?
非常感谢!
编辑
元素中的代码:
<?php echo $this->Form->create('Comment', array('class' => 'big', 'url' => array('controller' => 'comments', 'action' => 'add', $news_id)));?>
<?php
echo $this->Form->input('comment', array('label' => false));
?>
Form->end(__('Submit', true));?>
查看代码:
<?php echo $this->element('add_comment', array('news_id' => $news['News']['id'])); ?>
【问题讨论】:
-
您能否发布您的 Element 文件的代码以及您如何在视图中使用它?