zend 框架:zend 表单装饰器 - 删除乘法
我通过以下代码创建表单元素:
$input_new = $this->createElement('radio', 'Stars', array(
'label' => 'Stars',
'Options' => array('class'=>'star {split:2}'),
'multiOptions'=>array(
'1'=> '',
'2'=> '',
'3'=> '',
'4'=> '',
'5'=> '',
'6'=> ''
);
这是我得到的:
<label for="Stars" class="optional">Stars</label>
<label for="Stars-1"><input type="radio" name="Stars" id="Stars-1" value="1" class="star {split:2} in_line"></label><br />
<label for="Stars-2"><input type="radio" name="Stars" id="Stars-2" value="2" class="star {split:2} in_line"></label><br />
<label for="Stars-3"><input type="radio" name="Stars" id="Stars-3" value="3" class="star {split:2} in_line"></label><br />
<label for="Stars-4"><input type="radio" name="Stars" id="Stars-4" value="4" class="star {split:2} in_line"></label><br />
<label for="Stars-5"><input type="radio" name="Stars" id="Stars-5" value="5" class="star {split:2} in_line"></label><br />
<label for="Stars-6"><input type="radio" name="Stars" id="Stars-6" value="6" class="star {split:2} in_line"></label>
我也想删除每个输入和
标记,但主标签(星星)仍然保留。我怎样才能做到这一点?
I creating form element by this code:
$input_new = $this->createElement('radio', 'Stars', array(
'label' => 'Stars',
'Options' => array('class'=>'star {split:2}'),
'multiOptions'=>array(
'1'=> '',
'2'=> '',
'3'=> '',
'4'=> '',
'5'=> '',
'6'=> ''
);
Here what i got:
<label for="Stars" class="optional">Stars</label>
<label for="Stars-1"><input type="radio" name="Stars" id="Stars-1" value="1" class="star {split:2} in_line"></label><br />
<label for="Stars-2"><input type="radio" name="Stars" id="Stars-2" value="2" class="star {split:2} in_line"></label><br />
<label for="Stars-3"><input type="radio" name="Stars" id="Stars-3" value="3" class="star {split:2} in_line"></label><br />
<label for="Stars-4"><input type="radio" name="Stars" id="Stars-4" value="4" class="star {split:2} in_line"></label><br />
<label for="Stars-5"><input type="radio" name="Stars" id="Stars-5" value="5" class="star {split:2} in_line"></label><br />
<label for="Stars-6"><input type="radio" name="Stars" id="Stars-6" value="6" class="star {split:2} in_line"></label>
I want to remove at each input and
tag too, but main label(Stars) still stay. How i can do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,您的单选按钮可以转到显示组(字段集),因此您也可以删除按钮的所有标签并仅使用组标签。如果没有,您可能需要编写一个外部装饰器视图。我想不出更干净的方法来摆脱标签。
[编辑]
这是一个示例:
在表单中,像这样设置装饰器:
然后创建一个
starsview.phtml
文件。为了弄清楚如何创建视图脚本的内容,这些链接应该很有用:希望这有帮助。
Well, your radio buttons could go to a display group (a fieldset), so you could as well remove all labels for the buttons and just use the group label. If not, you'll probably need to write an external decorator view. I can't think of a cleaner way to get rid of the labels.
[EDIT]
Here's an example:
In the form, set the decorators like this:
Then create a
starsview.phtml
file. These links should prove useful in order to figure out how to create the view script's content:Hope this helps.