vivekcu
(Vivekcu 08)
October 17, 2013, 10:09am
1
guys…
this is the code that i have in my view
<div class="row">
<?php echo $form->labelEx($model, 'technology'); ?>
<ul><?php echo CHtml::activeCheckboxList($model, 'technology',CHtml::listData(Technology::model()->findAll(), 'tech_id', 'tech_name'),array('template'=>'<li>{label}{input}</li>'));?>
<div class="clearleft"></div>
</ul>
<?php echo $form->error($model, 'technology'); ?>
</div>
while creating i have stored the data from checkboxes in the database using implode.
i want the check box list to be pre selected when i go to the update form.
how can i do it?
faridplus
(Faridplusplus)
October 18, 2013, 10:00am
2
Hi, I don’t quite understand this part of your question:
Why would you use implode?! it’s true that you have multiple check boxes in your form but when the form is submitted only a single value will be returned and you should save 1 value in your db so there is no need for implode. If you do this then CHtml::activeCheckboxList() can select the right checkbox automatically.
guys…
this is the code that i have in my view
<div class="row">
<?php echo $form->labelEx($model, 'technology'); ?>
<ul><?php echo CHtml::activeCheckboxList($model, 'technology',CHtml::listData(Technology::model()->findAll(), 'tech_id', 'tech_name'),array('template'=>'<li>{label}{input}</li>'));?>
<div class="clearleft"></div>
</ul>
<?php echo $form->error($model, 'technology'); ?>
</div>
while creating i have stored the data from checkboxes in the database using implode.
i want the check box list to be pre selected when i go to the update form.
how can i do it?
Hi
did u added this in your rule method?
[color=#444444][font=Consolas, Menlo, Monaco,]array(‘technology’, ‘boolean’)[/font][/color]
Then its get saved… then it will automatically works as you expect
vivekcu
(Vivekcu 08)
October 25, 2013, 11:34am
4
Hi
did u added this in your rule method?
[color=#444444][font=Consolas, Menlo, Monaco,]array(‘technology’, ‘boolean’)[/font][/color]
Then its get saved… then it will automatically works as you expect
Thanks for your rep guyzzz
GSTAR
(Omzy83)
October 25, 2013, 10:35pm
5
Have you tried this in your controller:
$model = $this->loadModel();
$model->technology = explode(", ", $model->technology);