How to get blank checkboxes to pass as false to params

后端 未结 5 2175
北海茫月
北海茫月 2021-02-01 01:35

I have a form that is an update user form where several of the elements are checkboxes. I want true to pass to the params if checked (this is working) and false to pass to the

5条回答
  •  故里飘歌
    2021-02-01 02:27

    It appears that you are able to pass the value. See the following code:

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

    http://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag

提交回复
热议问题