Getting the value of TbSelect2

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

Answers


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


Need Your Help

Logging does not work for an exe file that is started by windows service

windows-services log4net logging console-application

*strong text*I have a windows service that starts a .Net console application (.exe file). This console app has logging enabled and I am using log4Net for logging. If I run the console app individua...

Can parameter types be specialized in PHP

php parameters types

Say we've got the following two classes:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.