Use custom id for check_box_tag in Rails

前端 未结 7 1027
时光说笑
时光说笑 2021-02-04 03:36

How do you set a custom id when using a check_box_tag helper in rails?

I have a loop which creates a bunch of checkboxes based on a collection:

- subject         


        
7条回答
  •  猫巷女王i
    2021-02-04 04:09

    HAML sample

    Lets say you have a print object somewhere with a framed attribute, you have to display a list of prints so inside the loop you will create a custom row and column with unique id on each checkbox for updating framed

    .input.row.collapse
      = check_box_tag :framed, print.framed, nil, { id: "framed_#{print.id}" }
    

提交回复
热议问题