php - How to load selected values in multiple-dropdown in update view in yii? -


i new in yii. have problem fetching selected values in dropdown when updating record.
have dropdown multiple selection of user's email.
when adding working fine, allows me select multiple values , can insert selected value's ids comma separated in database.
problem when want update record displays 1 selected record.

here code:

in view file:

<div class="controls">     <?php echo $form->dropdownlist($model, 'uid', $allusers, array('class' => 'select2-me input-sel_large', 'multiple' => 'true', 'options' => array('' => array('selected' => true)))); ?>         <?php echo $form->error($model, 'uid') ?> </div> 

in controller file:

$model = new user; $allusers = $model->getallusers(); 

in model file:

public function getallusers() {         $arr = yii::app()->db->createcommand()         ->select('useremail,pkuserid')         ->from('tbl_user')         ->queryall();         $users = array();         if (is_array($arr)) {             foreach ($arr $value) {                 $users[$value['pkuserid']] = $value['useremail'];             }         }         return $users;      } 

can help?

example. hope you.

class yourform extends cformmodel {     public $uid = array(); // selected pkuserid's }  //in action $yourform = new yourform(); $yourform->uid = array(1,2,3); // example selected users pk 1,2,3  $this->render('your_view', array('yourform'=>$yourform));  //view /** @var cactiveform $form */ /** @var yourform $yourform */ echo $form->dropdownlist(     $yourform,     'uid',     chtml::listdata(user::model()->findall(array('order' => 'useremail asc')), 'pkuserid', 'useremail'),     array('empty' => '', 'multiple'=>true))    ) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -