my view:
...
<?php echo CHtml::activeLabel($catForm,'suitable')?>
<?php
$form->widget('bootstrap.widgets.TbSelect2',array(
'model'=>$catForm,
'attribute'=>'suitable',
'data'=>Category::model()->getSubCategories('suitable'),
'options'=>array(
'placeholder'=>' -- please select -- ', // add this line
'allowClear'=>true,
),
'htmlOptions'=>array('multiple'=>'multiple',),
));
...
?>
My model:
class CategoryForm extends CFormModel
{
...
public $suitable;
...
}
My Controller:
public function actionCategories($id)
{
$catForm = new CategoryForm($id);
if(isset($_POST['CategoryForm'])){
...
}
$this->render('categories',array(
'model'=>$this->loadModel($id),
'catForm' => $catForm,
));
}
My question:
Is possible to populate in advance the Select2 with values that I store inside db before? I tried to pass the array on the __construct but it doesn’t work
Thanks is advance