dtamho6404 2015-03-29 04:46
浏览 872

Yii:在表单中使dropDownList只读/禁用

I am trying to make DropDownList readonly or disable in form for update condition but my code is not working ...

echo $form->dropDownListRow($model, 'sem_id', CHtml::listData(Sem::model()->findAll(), 'id', 'title'/*, array("disabled" => "disabled")*/ , array('readonly' => 'readonly') ));

Error: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members

  • 写回答

2条回答 默认 最新

  • doujiang1939 2015-03-29 05:59
    关注

    First thing is you should dropDownList instead of dropDownListRow. Also you forgot to use ) after 'title' And you should use "disabled" => "disabled" instead of 'readonly' => 'readonly'. I don't think they have a readonly attribute in html tags.

    echo $form->dropDownList($model, 'sem_id', CHtml::listData(Sem::model()->findAll(), 'id', 'title'), array("disabled" => "disabled"));
    

    This can make disabled dropdown list, but note that you can't relay on html attributes. Because the users can remove this attribute easily and can change dropdown value. So you need to have a control on your server.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?