Here is a example of some code that I use for my first project. It is with a DetailView, but a Modal won’t be any different I think
View with GridView:
...,
'columns' => array(
'email',
'firstName',
'lastName',
array(
'name' => 'isStudent',
'filter' => array(
'1' => 'Yes',
'0' => 'No'
),
'value' => array(
$this,
'studentInfo' //controller function for the HTML output
),
'type' => 'raw', //needed for the HTML output
'htmlOptions' => array('style' => 'text-align: center;', ),
),
Controller:
public function studentInfo($data, $row)
{
$student = Student::model() -> findByPk($data -> userId);
return $this -> renderPartial('../student/popup', array(
'user' => $data,
'student' => $student
), TRUE);
//set $return = true, don't display direct
}
View with DetailView or in your case a Modal:
if ($user -> isStudent == 1 && $student === NULL)
{
echo CHTML::link('<i class="icon-eye-open"></i>', array('user/update/' . $user -> userId . '#User_isActive'), array(
'rel' => 'tooltip',
'title' => Yii::t('app', 'Error: inconsistent data, please fix.')
));
}
elseif ($student !== NULL)
{
echo CHTML::link('<i class="icon-eye-open"></i>', array('student/view/' . $student -> studentId), array(
'data-title' => 'Info',
'data-content' => $this -> widget('bootstrap.widgets.BootDetailView', array(
'data' => $student,
'attributes' => array(
'studentCode',
'dateOfBirth',
'isAccessible',
'groupId',
'tempGroupId',
),
), true),
'rel' => 'popover'
));
}