如何获取bootstrap.widgets.TbSelect2的值 在数组中显示..
继承我的代码:
$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(',', ' ')
)
)
);
?>
由于
答案 0 :(得分:0)
试试这个; $ employees = Employee :: model() - > findAll(); $ emp = array(); foreach($ employees as $ emps){ array_push($ emps,$ emps ['id']。“。”。$ emps ['lastname']。“”。$ emps ['firstname']; }
标签不需要是索引数组,只需要是普通数组。见http://yiibooster.clevertech.biz/widgets/forms_inputs/view/select2.html