0

如何获取 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(',', ' ')
                                )
                     )
             );
?>

谢谢

4

1 回答 1

0

尝试这个; $employees = Employee::model()->findAll(); $emp = 数组();foreach($employees as $emps){ array_push($emps, $emps['id'].".".$emps['lastname']." ".$emps['firstname']; }

标签不需要是索引数组,只需一个普通数组。见这里http://yiibooster.clevertech.biz/widgets/forms_inputs/view/select2.html

于 2013-12-09T11:28:26.937 回答