samilo
(Samiloxphp)
1
Hi
I need to create check box list content for Example departments and user can check multiple box
With drowpdownlist I can load value like that :
model :
public function getsection(){
return array (
CHtml::listData(Csection::model()->findAll(),'section_id','ar_name'),
);
}
view :
...
echo CHtml::activedropDownList($models,'section_id', $models->getsection(),array('size'=>'4',
'prompt'=>'أSelect Sections ','multiple' => 'multiple',));
..
So how can i do that with checkboxlist , also how to process values in controller , is it like drowpdownlist ?
Thanks in advance
perochak
(Amjad Mughal)
2
If you want to get users selected values then you can do it as
$values=$_POST['model_name']['attribute_name'];
print_r($values);
the captured values will be an array.
Thanks
samilo
(Samiloxphp)
3
Thank you , how to load data from model into checklist ?!!
perochak
(Amjad Mughal)
4
In Model
public static function getList(){
return CHtml::listData(object::model()->findAll(),'id','name');
}
In Form
CHtml::activedropDownList($models,'section_id',Object::getList(),array('size'=>'4',
'prompt'=>'أSelect Sections ','multiple' => 'multiple',));
You can also do as
CHtml::activedropDownList($models,'section_id',CHtml::listData(Object::model()->findAll(),'id','name'),array('size'=>'4',
'prompt'=>'أSelect Sections ','multiple' => 'multiple',));