我如何自定义yii复选框html


how can i customize yii checkbox html

我是yii的新手,使用yii cgridview来显示记录。我想使用复选框来选择记录。

我想生成像

这样的HTML
<td>
    <label class="checkbox">
       <input type="checkbox" class="check">
       <i class="input-new"></i>
     </label>
</td>

得到的是

<td>
   <input type="checkbox" class="check">
</td>
我使用的代码是
array(
     'name' => 'check',
     'id' => 'selectedIds',
     'value' => '$data->rem_id',
     'class' => 'CheckBoxColumn',// <-- instead of CCheckBoxColumn
     'selectableRows' => '100',
     'headerTemplate'=>'<label class="checkbox">{item}<i class="input-new"></i></label>',
     'checkBoxHtmlOptions'=>array(
     'alt'=>'$data->rem_type','class'=>'check'),
 ),
有人能帮我做这件事吗?

我认为你需要在你的CheckBoxColumn类中覆盖renderDataCellContent功能。

:

<?php 
class CheckBoxColumn extends CCheckBoxColumn { 
    protected function renderDataCellContent($row,$data)
    {
        echo '<label class="checkbox">';
        echo $this->getDataCellContent($row);
        echo '<i class="input-new"></i>';
        echo '</label>';
    }
}

祝你好运!