yii dropdownlist selected items when update


how to make the multiple dropdown list can be selected in update option ?

ANS:

As I am getting the value dynamical, So, I have to make the list dynamically according to databases saved id and following yii convention…$result = Product::model()->findAllBySql($query);

                $selectedlist = CHtml::listData($result,’ProductID’, ‘ProductID’);
$x =  array();
foreach ($selectedlist as $key => $value) {
//$selectedlist[$key]=’array(“selected”=>”selected”)’;
$x[$key]=array(“selected”=>”selected”);
}$list=CHtml::listData( Product::model()->findAllBySql(SELECT ProductID, ProductName
FROM product ORDER BY ProductName ASC’),’ProductID’, ‘ProductName‘);

echo $form->dropDownList($model,’ClientIDs’,$list, array(  ‘empty’=>’——Select multiple clients——’,

    ‘options’=>$x,
                ‘size’=>”5″,
                ‘value’ => ‘Y’,
                ‘uncheckValue’=>’N’,
               //’name’=>’categoryList’,
                ‘multiple’=>’multiple’,
                ‘style’=>’width:250px;’)
);

============================== Another way==========

But, in this way, you will able to make the items selected but, that value you will not able to use, when update.

This is:

echo Chtml::dropDownList(‘ClientIDs’,$selected, $list, array(  ‘empty’=>’——Select multiple clients——’,));

About these ads

2 thoughts on “yii dropdownlist selected items when update

  1. sandy

    Great beat ! I would like to apprentice whilst you amend your website, how could i subscribe for a blog web site? The account helped me a appropriate deal. I had been tiny bit acquainted of this your broadcast provided vivid clear concept

    Reply
  2. Pingback: white paper

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s