PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 12, 2022

[FIXED] error using multiselect with EChosen extension Yii

 January 12, 2022     dropdown, multipleselection, php, yii     No comments   

Issue

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


Solution

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 = '';
            }


Answered By - Trainee
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing