2
votes

I have a news controller with a 'view' action 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'])); ?>
1
Can you post the code of your Element file and how you use it in your view?unicorn_crack

1 Answers

2
votes

move the code from your view into an element and then call the element all over the place.