How to load selected list items in multiple-select-listbox in update view in yii? -
i have multiple select-list-box staff in create-service-form, used select multiple staff when creating new service. can assign multiple staff on single service.
i saved staff_id field as: $model->staff_id = serialize($model->staff_id);
here update-view code multiple-select-list-box:
<div class="row"> <?php echo $form->labelex($model,'staff_id'); ?> <?php $data = array('1' => 'sam', '2' => 'john', '3' => 'addy'); $htmloptions = array('size' => '5', 'prompt'=>'use ctrl select multiple staff', 'multiple' => 'multiple'); echo $form->listbox($model,'staff_id', $data, $htmloptions); ?> <?php echo $form->error($model,'staff_id'); ?> </div> problem is, when load form updating service. how select staff, saved in database?
i tried this dropdownlist-attributes, not working.
$select | string | selected value
if has solution, suggest me. mates...
here's quick code wrote you, example understand how works.
<div class="row"> <?php echo $form->labelex($model,'staff_id'); ?> <?php $data = array('101' => 'faraz khan', '102' => 'depesh saini', '103' => 'nalin gehlot', '104' => 'hari maliya'); $selected = array( '102' => array('selected' => 'selected'), '103' => array('selected' => 'selected'), ); $htmloptions = array('size' => '5', 'prompt'=>'use ctrl select multiple staff', 'multiple' => 'true', 'options' => $selected); echo $form->listbox($model,'staff_id', $data, $htmloptions); ?> <?php echo $form->error($model,'staff_id'); ?> </div> have fun ya !!!
Comments
Post a Comment