How to renderPartial a file from another controller’s view folder

Hi, guys.

I’m working with CJuiTabs which will create tabs in layout.

How can I use renderPartial a file in another controller’s view folder to include a view into each tab?

I’d tried follwing code:

$this->widget('zii.widgets.jui.CJuiTabs', array(


          	'Organisation' =>$this->renderPartial("_form", array('model' => $model), $this),

          	'Contact Person' =>$this->renderPartial("contactPerson/_form", array('model' => $model), $this),

          	'Address' =>$this->renderPartial("address/_form", array('model' => $model), $this),






Now I am getting the following error:

AbcController cannot find the requested view "contactPerson/_form".

and AbcController cannot find the requested view "Address/_form".

My view path is: /protected/views/contactPerson and /protected/views/address

Thanks in advance.

Is not a good practice to use view from different controller.

If you want to re-use a view (or maybe just a part of) create a widget.

Add a class in components:

public class myWidget extends CWidget


  public function run()





The view should be placed in protected/components/view.

With this schema you can move any eventually shared controller’s code in the function run.

Thank you :)

Try renderFile



zaccaria, не могли бы ответить на вопрос, связанный с этой темой?

Есть необходимость в разных представлениях подключать набор разных виджетов. То есть компоновать этот набор из нескольких стандартных. Есть идея использовать renderPartial, но вы пишете что это плохая практика и лучше использовать переопределение виджетов. Можете объяснить почему или дать ссылку, чтобы почитать об этом?

I speak russian quite well, but I write it very slow, so I prefer to answer in english (also other users in the forum can read it).

Widget are more powerfull, the can easiliy customized by adding property and can manage input, like for example a login widget you show in each page.

Take a look at the doc here and this example of usage

Thank you very much!

I asked about this at Alexander Makarov (it is one of the core developers Yii). He said that you can use as widgets and renderPartial. Without a difference.

This works for me:

$this->renderPartial('', array());

You have to identify as the tree folder like this: protected/modules/news/views/view_file.php


in View file call widget like



                    'caseId' =&gt; &#036;case_id,



file path : protected/modules/recruitment/components/CaseDetails.php

class CaseDetails extends CWidget {

$this->render(’_showCaseDetails’,array(‘model’ => $case),false,true);


File path : protected/modules/recruitment/components/_showCaseDetails.php

#this will call view file of my module.

Yii::app()->controller->renderPartial(‘application.modules.recruitment.views.recruitment._view’, array(‘model’ => $model) );

This works for me like charm!!!