Reputation: 127
I am using CHtml::checkBoxList in my Yii application. I need to disable few checkboxes based on some criteria. How can I do that using Yii itself?
Below is my code
echo CHtml::checkBoxList('sid','',$posts1, array('id'=>'1','template' => '{input}{label}</td></tr><tr><td width="10%" style="padding:0 0 10px 20px;" class="rbr">','checkAll' => 'All'));
This will generate a table similar to the image below
What I need is to disable the checkbox corresponding to the first row. i.e., the check box with 4X-B in its row.
Any help in this regard will be highly appreciated.
Upvotes: 0
Views: 1636
Reputation: 4160
create an Action as
public function actionIndex() {
$model= new CActiveDataProvider('ModelClass');
$this->render('index',array('model' => $model));
}
In Index.php view file
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model,
'columns' => array(
array(
'class' => 'CCheckBoxColumn',
'disabled' => '$data->last_column=="4X-B" ? true : false',
),
'country',
'last_column'
)
));
?>
Read CGridView
Upvotes: 0
Reputation: 11302
It is impossible using CHtml class. You can create custom Html class
. Or use foreach
to generate html.
Upvotes: 1