cakephp:删除单选按钮中所有选项中的星星

发布于 2025-01-07 17:03:39 字数 1431 浏览 7 评论 0原文

我的表单中有一个单选按钮,使用以下代码

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-残月青衣踏尘吟 2025-01-14 17:03:39

我不喜欢使用图例,所以我在无线电列表之前添加了一个标签:

Form->label('radioname', __('Label:', true), '必需的'); ?>

然后调整新标签和单选按钮标签的 css:

label.required:after {
  color: #e32;
  content: '*';
  display:inline;
}

.radio label{
  font-weight:normal;
}
.radio label:after{
  display:none !important;
}

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:

label.required:after {
  color: #e32;
  content: '*';
  display:inline;
}

.radio label{
  font-weight:normal;
}
.radio label:after{
  display:none !important;
}
滿滿的愛 2025-01-14 17:03:39

有一个名为 legend 的属性,其名称用于对所有无线电进行分组

echo $form->input('Users.vote', array(
 'type' => 'radio',
 'legend' => 'Vote*',
 'class' => 'vote',
 'options' => array('1' => 'a', '2' => 'b', '3' => 'c' ),
));

Have an attribute called legend with a name to group all radio

echo $form->input('Users.vote', array(
 'type' => 'radio',
 'legend' => 'Vote*',
 'class' => 'vote',
 'options' => array('1' => 'a', '2' => 'b', '3' => 'c' ),
));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文