我正在使用 Zend Frameworks ViewHelpers。 我正在尝试传递一些内容以在 SELECT 中设置禁用属性。例如如果
$countries = array(1=>'Select Option', 2=>'us', 3=>'uk')
和
formSelect('country','us',null,$this->countries)
我需要禁用第一个选项,即“选择选项”
你有什么想法吗?
提前致谢
最佳答案
我不认为你可以禁用一个元素?如果您禁用它,那为什么还要使用它呢?
您只能禁用整个 <select>
输入。
建议你写验证不接受第一个元素。
在 OP 关于能够做到这一点的评论之后进行编辑
这是另一个答案
// Get the countries element (do this after adding your options), then set the
// attribute disable for option '1'
$form->getElement("countries")->setAttrib("disable", array(1));
这是建议here
关于php - 如何使用 Zend Framework 中的 ViewHelper 设置 Select lke disabled ='disabled' 的任何属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3609355/