how to get the value of bootstrap.widgets.TbSelect2 display in array..
heres my code:
$employees = Employee::model()->findAll();
$ctr = 0;
$emp = '';
foreach($employees as $emps){
$emp[$ctr]=$emps['id'].". ".$emps['lastname']." ".$emps['firstname'];
$ctr++;
}
$this->widget(
'bootstrap.widgets.TbSelect2',
array(
'asDropDownList' => false,
'name' => 'emp_sel',
'options' => array(
'tags' => $emp,
'placeholder' => 'Type the name of employee and press enter to select',
'width' => '100%',
'tokenSeparators' => array(',', ' ')
)
)
);
?>
Thanks
Try this; $employees = Employee::model()->findAll(); $emp = array(); foreach($employees as $emps){ array_push($emps, $emps['id'].". ".$emps['lastname']." ".$emps['firstname']; }
The tags doesn't need to be an indexed array, just a plain array. See here http://yiibooster.clevertech.biz/widgets/forms_inputs/view/select2.html