How to make checkboxes selected on update!! i have been trying this but i unsuccessfull.please help me out?
How to make checkboxes selected on update!! i have been trying this but i unsuccessfull.please help me out?
Hi
you can write this
echo CHtml::checkBoxList('designation_id', 'designation_id', CHtml::listData(VenueDesignation::model()->findAll("status='1'"),'id','designation_name'), array('options' => array($resultSet->designation_id => array('selected' => true),'class'=>'col_165')));
In this $resultSet->designation_id is your checkboxlist id
hey thanks for the reply but iam not using CHtml iam using cactiveform
Hi
you can try the code
<?php if(isset($_GET['id']) && !empty($_GET['id'])): ?>
<?php
$values=array();
foreach($model_inter as $data){
if($data->rk_intersted_id!=''){
$values[]=$data->rk_intersted_id;
}
}
$categories = CHtml::listData(VendorIntersted::model()->findAll("status='1'"), 'id', 'intersted_name');
$preSelectedCategories = $values;
echo CHtml::checkBoxList('rk_intersted_id',$preSelectedCategories,$categories,array('template'=>'<li><span class="music">{input}</span>{label}</li>','separator'=>''));
?>
<?php else: ?>
<?php
echo CHtml::activeCheckboxList($model, 'rk_intersted_id',
CHtml::listData(VendorIntersted::model()->findAll("status='1'"), 'id', 'intersted_name'),
array('template'=>'<li><span class="music">{input}</span>{label}</li>','separator'=>'',)
);
?>
<?php endif; ?>
Hi ankit,
thanks for the reply it worked!!
Hi
Have u done it using cactiveform ? if done please post your code so some may be helpful for it.
Hi,
here is the solution how i solved it…
if(isset($_GET[‘id’])){
$values = "";
if($model->customerlist!=''){
$values = $model->customerlist
}
$preSelectedList = $values;
echo CHtml::checkBoxList('Customer['cust_list'][]',$preSelectedList,$model->cust_list,array('style'=>'float: left;margin-right: 5px'));
}
else{
echo $form->checkBoxList($model,'cust_list',$model->cust_list,array(
'style'=>'float: left;margin-right: 5px',
)
);
}
Customer[‘cust_list’][] - this is the name of the checkbox which should be same as checkboxlist names in else block. (viewed it using firebug) - this step is more inportant.
$model->cust_list - this is the whole list of values you want to display
Hi
it’s also better then if u write
if(isset($_GET['id'])){
$values = "";
if($model->customerlist!=''){
$values = $model->customerlist
}
$preSelectedList = $values;
echo CHtml::checkBoxList('Customer['cust_list'][]',$preSelectedList,$model->cust_list,array('style'=>'float: left;margin-right: 5px'));
}