cakephp:删除单选按钮中所有选项中的星星
我的表单中有一个单选按钮,使用以下代码
echo $form->input('Users.vote', array(
'type' => 'radio',
'label' => array('text' => __("form_vote", "true"), 'class' => 'vote'),
'options' => array('1' => 'a', '2' => 'b', '3' => 'c' ),
));
这是我的投票模型验证
'vote' => array(
'rule' => 'inList', array(1,2,3),
'allowEmpty' => false,
'required' => true,
'message' => 'error_vote'
)
问题是它在 a、b 和 c 选项旁边添加了一个 *。这是一个屏幕截图,展示了所有三个选项上都有星星的情况。 http://imageshack.us/photo/my-images/23/radiojpg。 jpg/ 我希望星星只显示在“投票”标签上
这是 html 输出
<div class="input radio required"><fieldset><legend>Vote</legend><input type="hidden" value="" id="UserVote_" name="data[User][vote]">
<input type="radio" value="1" id="UserVote1" name="data[User][vote]">
<label for="UserVote1">a<span class="red">*</span></label>
<input type="radio" value="2" id="UserVote2" name="data[User][vote]">
<label for="UserVote2">b<span class="red">*</span></label>
<input type="radio" value="3" id="UsertVote3" name="data[User][vote]">
<label for="Vote3">c<span class="red">*</span></label></fieldset></div>
I have a radio button in my form using the following code
echo $form->input('Users.vote', array(
'type' => 'radio',
'label' => array('text' => __("form_vote", "true"), 'class' => 'vote'),
'options' => array('1' => 'a', '2' => 'b', '3' => 'c' ),
));
This is my model validation for vote
'vote' => array(
'rule' => 'inList', array(1,2,3),
'allowEmpty' => false,
'required' => true,
'message' => 'error_vote'
)
Problem is that it adds a * right next to the a, b and c choices. Here is a screengrab on what it looks like with the stars on all three choices. http://imageshack.us/photo/my-images/23/radiojpg.jpg/
I'd like the star to only be displayed on the label 'Vote'
Here is the html output
<div class="input radio required"><fieldset><legend>Vote</legend><input type="hidden" value="" id="UserVote_" name="data[User][vote]">
<input type="radio" value="1" id="UserVote1" name="data[User][vote]">
<label for="UserVote1">a<span class="red">*</span></label>
<input type="radio" value="2" id="UserVote2" name="data[User][vote]">
<label for="UserVote2">b<span class="red">*</span></label>
<input type="radio" value="3" id="UsertVote3" name="data[User][vote]">
<label for="Vote3">c<span class="red">*</span></label></fieldset></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不喜欢使用图例,所以我在无线电列表之前添加了一个标签:
Form->label('radioname', __('Label:', true), '必需的'); ?>
然后调整新标签和单选按钮标签的 css:
I don't prefer using legends so I added a label before the radio list:
<?php echo $this->Form->label('radioname', __('Label:', true), 'required'); ?>
Then adjusted the css for the new label and the radio button labels:
有一个名为 legend 的属性,其名称用于对所有无线电进行分组
Have an attribute called legend with a name to group all radio