Zend Form Radio Multioption Title Attribute

时间:2012-10-15 08:23:28

标签: php html zend-framework zend-form

我的问题是;是否可以为Zend表单上的每个单选按钮添加唯一的title属性?

到目前为止我的代码是:

$this->addElement('radio', 'vtype', array('label'=>'Type of Visit:'));
$vtype = $this->getElement('vtype');
$vtype->addMultiOption("A","A");
$vtype->addMultiOption("B","B");
$vtype->addMultiOption("C","C");
$vtype->addMultiOption("D","D");
$vtype->addMultiOption("E","E");
$vtype->setAttribs(array('label_class'=>'radio_label'));
$vtype->setSeparator("");
$vtype->setDecorators($myDecorators);

更新 - 如果可能,这就是我想要实现的目标:

<input type="radio" name="vtype" title="Click A for some reason" value="A" />
...
<input type="radio" name="vtype" title="Click E for some reason" value="E" />

1 个答案:

答案 0 :(得分:1)

我建议你在jquery中这样做:

$("#form input[radio]").each(){
  $(this).attr('title', 'Click ' + $(this).val() + ' for some reason');
});