yii method to disable selected options from multi select dropdown

妖精的绣舞 提交于 2019-12-08 05:34:15

问题


I am using yii dropdown with active records in that i am using multiselect dropdown. i am creating data with in which i am selected multiple option from dropdown.. while updating i want to disable selected option which i selected at time of creation.

<code>
<?php 
$savedSections  =   helpers::getQuestionnaireSectionList($model->questionnaire_id);

$data   =   helpers::getSection();

$listData       =   CHtml::listData($data, 'section_id', 'section_name');

$htmlOptions = array('size' => '5', 'multiple' => 'true','style'=>'width: 333px');

$queSection->section_ref_id =   $savedSections; #sec2

echo $form->listBox($queSection,'section_ref_id',$listData, $htmlOptions); #sec1

?>

<code>

now here #sec1 is showing output with multiple option and i am also getting selected options but i want to disabled all the selected option which is coming from #sec2

Please help me if you have any idea.

regards anil


回答1:


change your $htmlOptions to be like this:

$htmlOptions = array(
    'size' => '5',
    'multiple' => 'true',
    'options'=>array(45=>array('disabled'=>'disabled')),
);

45 here is a section_id

and if you want to find out how it's implemented you can take a look a this https://github.com/yiisoft/yii/blob/master/framework/web/helpers/CHtml.php#L2516



来源:https://stackoverflow.com/questions/16604719/yii-method-to-disable-selected-options-from-multi-select-dropdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!