I have 2 models suppose A and B which contain two separate forms. I want to show the content of开发者_运维问答 form B on the view page of model A. So how to render the content of B on A. Any help on this will be highly appreciable.
You need to pass the B model to the view of the A model, if you're using the code generated by Yii's CRUD for example in the AController file you can modify it into this:
public function actionView()
{
$BModel = B::model()->findAll();
$this->render('view',array(
'model'=>$this->loadModel(),
'othermodel'=>$BModel,
));
}
after adding the 'othermodel' into the view function, you should be able to access $othermodel in the view.php file
Just do a renderPartial of the view of model B into the view of model A:
// This is _formA
...
$modelB = new ModelB();
echo $this->renderPartial('/modelB/_formB',array('model'=>$modelB));
...
精彩评论