rails check_box_tag 使用默认值设置检查 [英] rails check_box_tag set checked with default value

查看:25
本文介绍了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 怎么办(我只想使用默认值).或者类似地,如果我想指定 html 选项而不指定 checked 属性怎么办.有没有办法做到这一点?

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屋!

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