How to check a check box in Haml using check_box_tag

前端 未结 6 1661
醉梦人生
醉梦人生 2020-12-17 17:18

Can someone tell me how to set these check boxes to checked? I\'m sure it\'s simple, but after an hour of trying i think I need to ask! Thanks!

= form_tag mo         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-17 17:33

    Building on the answer by Sali. Strangely, the check_box_tag returns a checkbox with no label text. Here's how you can display text if you're iterating over an array.

    - Puppies.each do |puppy|
      = check_box_tag(puppy.name, puppy.name, puppy.goodboy?)
      = puppy.name
    

提交回复
热议问题