I'm using Yii and I want to make a multiselect dropdown by using EChosen extension.
Here is my form code:
<div class="control-group">
<?php echo $form->labelEx($model,'PROJ_PLATFORM', array('class'=>'control-label')); ?>
<div class="controls"><?php
echo Chosen::multiSelect($model, 'PROJ_PLATFORM', (CHtml::listData (MstEmailBody::model()->getList(),'CODE_NM', 'CODE_NM')),
array(
'empty'=>'asdasdasd',
// 'data-placeholder' => 'Tags',
'options'=>array(
'maxSelectedOptions' => 3,
'displaySelectedOptions' => true,
)));
?>
<span class="help-inline text-error"><?php echo $form->error($model,'PROJ_PLATFORM'); ?></span>
</div>
</div>
But I got this error:
Object of class MstEmailBody could not be converted to string
What causes this error? I have brows but I still got no solution.
Can someone help me? Thanks in advance
well this is the solution for my problem
veiw:
Chosen::activeMultiSelect($model, 'PIC_BSA', (CHtml::listData (MstResource::model()->getListBsa(),'RES_CD', 'RES_NM')),
array(
// 'data-placeholder' => 'Tags',
'options'=>array(
// 'maxSelectedOptions' => 3,
'displaySelectedOptions' => true,
)));
form:
echo $form->dropDownlist($model,'PIC_BSA',
(CHtml::listData (MstResource::model()->getListBsa(),'RES_CD','RES_NM')),
array(
'multiple'=>true,
));
controller:
$model->PIC_BSA = explode(",", $model->PIC_BSA);
if(isset($_POST['TrnProjectIT']['PIC_BSA'])){
$pic_bsa = implode(",",$_POST['TrnProjectIT']['PIC_BSA']);
$model->PIC_BSA = $pic_bsa;
}else{
$model->PIC_BSA = '';
}