我的问题是:是否可以为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" />

最佳答案

我建议您在jquery中这样做:

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

09-27 13:06