rails check_box_tag set checked with default value

后端 未结 6 1415
说谎
说谎 2021-02-18 14:38

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

6条回答
  •  既然无缘
    2021-02-18 14:59

    check_box_tag(name, value = "1", checked = false, options = {})

    Examples:

    check_box_tag 'receive_email', 'yes', true
    # => 
    
    check_box_tag 'tos', 'yes', false, class: 'accept_tos'
    # => 
    
    check_box_tag 'eula', 'accepted', false, disabled: true
    # => 
    

    api.rubyonrails.org

提交回复
热议问题