dongwei1855 2017-02-16 04:35
浏览 30
已采纳

Zend元素 - 如何禁用特定的选择/下拉列表

As the title say, I have select/dropdown list on my web using code below

<?php
class Application_Form_Element_BranchDropdownDisabled extends Zend_Form_Element_Select {
    public function init() {
        $branch = new Application_Model_DbTable_Branch();
        $this->addMultiOption(0, ' ');
        foreach ($branch->fetchAll() as $branch) {
            if($branch['disabled']==false){
                $this->addMultiOption($branch['branch_id'], $branch['branch_name']);
            }else{
                //i want to add multioption but disabled
            }
        }
    }
}
  • 写回答

1条回答 默认 最新

  • dongxinche1264 2017-02-16 07:11
    关注
    Both ZF! and Zf2 doesn't provide a way to disable specific option on select/dropdown list. So you have to do it using javascript. So add a class to disabled options and disable it by js.
    
    <select>
      <option value="Opt 1">Opt 1</option>
      <option class="disabledOption" value="Disabled value">Disabled option</option>
    </select>
    
    $(".disabledOption").attr("disabled", "disabled");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码