Hi , Please is it possible to call a function from a different controller inside a another view
I have a view post/view.php ; and I have a controller CommentController.php
inside CommentController I have function create
public function Create($cmt, $pid, $rid)
{
$model = new Comments();
$acc_comment = new AxComment;
if ($model->load(Yii::$app->request->post()) )
{
$acc_comment->CreateComment($model, $pid, $rid);
return $this->redirect(['chn/channel', 'id' => $cmt]);
}
return $this->renderPartial('_form', [
'model' => $model,
]);
}
I want to call this action inside post/view
use frontend\controllers\CmmtController;
$cmmt = new CmmtController();
<div class="crForm-comment">
<?php echo $cmmt->Create($model->channel->channel_uid, $model->post_id, $model->user_id); ?>
</div>
I get this error :
Missing argument 1 for yii\base\Controller::__construct(), called in I:\zzerver\uwmp-php7\u7000\www\yii2b\frontend\views\post\view.php on line 15 and defined