rails check_box_tag设置为默认值 [英] rails check_box_tag set checked with default value
本文介绍了rails check_box_tag设置为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有一个看起来像Rails的check_box_tag呼叫
I currently have a rails check_box_tag call that looks like
check_box_tag #{name}
我想添加一个选中的属性,我知道我可以使用
I want to include a checked attribute, which I know I can do with
check_box_tag name, value, checked
但是如果我想将其设置为选中而不显式指定value
(我只想使用默认值)怎么办.或类似地,如果我想在不指定checked
属性的情况下指定html选项,该怎么办.有办法吗?
But what if I want to set it to checked without explicitly specifying value
(I just want to use the default). Or similarly, what if I wanted to specify html options without specifying the checked
attribute. Is there a way to do this?
推荐答案
只想更新此内容. check_box_tag
的第三个参数是代表检查状态的布尔值.
Just wanted to update this. The third parameter for check_box_tag
is a boolean value representing the checked status.
check_box_tag name, value, true
这篇关于rails check_box_tag设置为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文