Use custom id for check_box_tag in Rails

前端 未结 7 1002
时光说笑
时光说笑 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条回答
  • 2021-02-04 04:11

    Leito,

    Just to close the loop, I gave up trying to pass an object type indicator in through check_box_tag. Every parameter I added to the syntax shown in my last post above (below??) simply caused the checkbox state to default to checked rather than unchecked, without passing any additional data to the controller.

    While remaining alert to alternative solutions as they present themselves, for the time being I incorporate the object type into the submit_tag value. This ties the functionality to the display, since the submit_tag value is what's shown to the user on the submit button, but it could be argued that this forces clarity into the view even as it provides needed disambiguation to the controller.

    Learning day by day...

    0 讨论(0)
提交回复
热议问题