Open A View In Modal.

Problem :

2 Controllers


Controller 1

View 1

Controller 2

View 2

in view 1 I already have a link


which opens up view 2 but not as a modal.

I want to know how I can open "View2" as a Modal using the


from view 1

Looks like yii 1 question. I think there are probably lots of other better answers in posts in the yii1 forum re this and examples with the extension. Apologies if I get it wrong or mis-interpret your question but will try anyway.

Unless using ajax to bring in the modal contents you will render view 2 inside of modal inside view 1, and then use a button or link to show the modal. The modal exists in the html but is hidden and then exposed by javascript when you click a button or something.

Its been a while and this is untested, but perhaps something like below inside view1.

// modal where path_to_view2 is path to your view2 file

$this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'myModal'));

    echo '<div id="form-modal" class="modal-body">';

    echo $this->getController()->renderPartial('path_to_view2', array('model'=>$this->model));

    echo '</div>';


// button to show the modal

$this->widget('bootstrap.widgets.TbButton', array(

    'label' => 'Open modal',

    'url' => '#myModal',

    'type' => 'primary',

    'size' => 'small', // '', 'large', 'small' or 'mini'

    'htmlOptions' => array(

        'data-toggle' => 'modal',



this is good! but my view is under another controller… so renderPartial doesnt work :(

Apologies - I missed the second controller bit.

Try following suggestion from the below link, I don’t think it is recommended to do it how you are intending but there are other ways around it. See: