I’ve attempted to render two views on one page, using a range of potential options out there.
In this case, the two views come from different controllers.
I can see that in Yii 1, the main method to render two views was to use the renderPartial function. Apparently, Yii2 doesn’t use this, and that you can use the main render function off the controller, as suggested here:
I suppose your problem is not the renderPartial, but rather the code which renders your create button to use the complete url with the right controller. I presume this button rendering code is in your index.php view file.
You must change this the create button code to something this:
So, while i can get this to work, I am concerned that it’s more of a hack than it should be. I expect that much of these linking issues would not be a problem if I called the controller somehow within the site/index view.
I don’t see anything wrong with the explicitly set URLs and the approach you use, especially if it goes along with your project design. According to the docs, ‘controller’ option is provided exactly for the purposes you use it for.
There’s one more approach that might work, though I don’t think there’s any beauty in this approach anyway. So I’m giving a quick example only for a study purposes:
public function actionIndex()
// SiteController actionIndex()
$test = new TestController('test', $this->module);
return $this->render('index', ['test'=>$test]);