I have a news controller with a 'view' 开发者_如何学Pythonaction for each news item. In the 'view' action of each news item I would like to include another view, the 'add' action of the comments controller. Basically, I need a form on each news item's page to add comments. I have the two views but I can't manage to link them. I tried with elements, but it seems it doesn't render the view for the add comment view.
What should I do?
Thank you very much!
EDIT
Code in element:
<?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));?>
Code in view:
<?php echo $this->element('add_comment', array('news_id' => $news['News']['id'])); ?>
move the code from your view into an element and then call the element all over the place.
精彩评论