使用哈希元素作为单选按钮 [英] Using elements of a Hash as radio Button

查看:29
本文介绍了使用哈希元素作为单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在其中创建一项运动,并且任何用户都可以通过选择它来注册该运动.我正在尝试使用单选按钮,因为我打算让任何用户都能够选择多个按钮,但是我遇到了 radio_button_tagcollection_radio_button 问题.collection_radio_button 只显示一个选项,两个选项都需要一个标签.我希望能够将视图中创建的运动(使用单选按钮)作为散列传递,以便在用户创建运动时可以动态增加或减少它.另外请问还有其他可行的选项,不一定是单选按钮.

I have an application in which a user can create a sport, also any user can register to the sport by selecting it. I'm trying to use radio buttons as i intend for any user to be able to select more than one, but i'm having issues with radio_button_tag and collection_radio_button . collection_radio_button only shows one option and both still needs a label. I want to be able to pass the sports created in the view (using radio button) as a hash so that it can be dynamically increased or reduced as the sports are created by users. Also please is there another option that's workable and not necessarily radio buttons.

推荐答案

这里,场景应该允许用户添加多个运动.所以你应该使用复选框,代码是

Here,the scenario should allow user to add multiple sports.so you should use checkboxes and the code is <label>Cricket<input type="checkbox"/></label>

这篇关于使用哈希元素作为单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆