yii方法来禁用多选下拉菜单中的选定选项 [英] yii method to disable selected options from multi select dropdown

查看:129
本文介绍了yii方法来禁用多选下拉菜单中的选定选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将yii下拉列表与活动记录一起使用,因为我正在使用multiselect下拉列表.我正在创建从下拉菜单中选择多个选项的数据.在更新时,我想禁用在创建时选择的所选选项.

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>

现在这里#sec1显示带有多个选项的输出,我也正在获取选定的选项,但是我想禁用所有来自#sec2的选定选项

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.

致谢 尼尔

推荐答案

将您的$htmlOptions更改为:

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

45这是section_id

,如果您想了解它是如何实现的,可以看一下 https://github.com/yiisoft/yii /blob/master/framework/web/helpers/CHtml.php#L2516

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

这篇关于yii方法来禁用多选下拉菜单中的选定选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆