2

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

到目前为止,我的代码是:

$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" />
4

1 回答 1

1

我建议你在 jquery 中这样做:

$("#form input[radio]").each(){
  $(this).attr('title', 'Click ' + $(this).val() + ' for some reason');
});
于 2012-10-16T09:51:36.580 回答