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

查看:22
本文介绍了使用默认值检查 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天全站免登陆