问题
Yii is the best but I'm have two models , book and author . I need to process two forms for each one in a single view , as I do this in yii2.0 .
<?=
$this->render('_formBook', array('model' => $model));
?>
<?=
$this->render('_formAuthor', array('model' => $model));
?>
回答1:
try this way
In your Controller
$modelBook = Book::findOne($id);
$modelAuthor = Author::findOne($key);
return $this->render('_formWithTheTwoForm',
'modelBook' => $modelBook,
'modelAuthor' => $modelAuthor,]);
Then in your view you can use both the model
来源:https://stackoverflow.com/questions/34144553/yii2-render-two-models-in-one-view