Zend_form_element_radio 无法将类添加到标签
我试图向一组单选按钮中的每个标签添加一个类(相同)。
这是我的代码:
$linkedin_share = new Zend_Form_Element_Radio('linkedin_share', array('escape' => false));
$linkedin_share->setDecorators(array('ViewHelper','Errors', array('Label', array('class' => 'TEST'))))
->addMultiOption('none', $this->getView()->translate('None'))
->addMultiOption('icon', '<img src="'.$this->getView()->baseUrl().'/images/admin/icons/social_media_share/linkedin.png'.'"/>')
->addMultiOption('counter', '<img src="'.$this->getView()->baseUrl().'/images/admin/icons/social_media_share/linkedin_share.jpg'.'"/>')
->setSeparator('')
->setAttrib('class', 'item_small_checkbox');
这是我的输出:
<label for="linkedin_share-none">
<label for="linkedin_share-icon">
<label for="linkedin_share-counter">
这是我想要的输出:
<label for="linkedin_share-none" class="share_label_class">
<label for="linkedin_share-icon" class="share_label_class">
<label for="linkedin_share-counter" class="share_label_class">
愚蠢的是,到目前为止它适用于我的所有其他表单元素。我尝试了一百万种组合并搜索了我的屁股,但无论我尝试什么,我都无法为标签添加类别。
非常欢迎想法、解决方案、建议!提前致谢!
I'm trying to add a class (the same) to each label in a group of radio buttons.
This is my code:
$linkedin_share = new Zend_Form_Element_Radio('linkedin_share', array('escape' => false));
$linkedin_share->setDecorators(array('ViewHelper','Errors', array('Label', array('class' => 'TEST'))))
->addMultiOption('none', $this->getView()->translate('None'))
->addMultiOption('icon', '<img src="'.$this->getView()->baseUrl().'/images/admin/icons/social_media_share/linkedin.png'.'"/>')
->addMultiOption('counter', '<img src="'.$this->getView()->baseUrl().'/images/admin/icons/social_media_share/linkedin_share.jpg'.'"/>')
->setSeparator('')
->setAttrib('class', 'item_small_checkbox');
And this is my output:
<label for="linkedin_share-none">
<label for="linkedin_share-icon">
<label for="linkedin_share-counter">
This is my desired output:
<label for="linkedin_share-none" class="share_label_class">
<label for="linkedin_share-icon" class="share_label_class">
<label for="linkedin_share-counter" class="share_label_class">
The stupid thing is that it works for all my other form elements so far. I tried a million combinations and searched my ass off, but no matter what I try I can't add class to the label.
Ideas, solutions, suggestions are all very welcome! Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我花了两个小时才找到答案,而且答案非常简单!将此行添加到您的声明中:-
Zend/View/Helper/FormRadio.php 第 79 - 95 行给了我线索。
这适用于我的系统,我希望它也适用于您。
It took me two hours to find the answer and it's infuriatingly simple! Add this line to your declaration:-
Zend/View/Helper/FormRadio.php line 79 - 95 gave me the clue.
This works on my system, I hope it does for you too.
试试这个:
或者
//linkedin_share
try this:
OR
//linkedin_share