How do I set a unique ID for checkboxes in a multi-record Rails form?

前端 未结 4 694
太阳男子
太阳男子 2021-01-06 21:55

I\'ve set up a Rails form roughly following the instructions in this Railscast.

Here\'s the code for the form:

<% form_tag complete_todos_path, :m         


        
4条回答
  •  没有蜡笔的小新
    2021-01-06 22:38

    <%= check_box_tag "todo_ids[]", todo.id, false, :id => "todo_id_#{todo.id}" -%> or whatever you want the id to be.

    I consider this a bug with check_box_tag caused by the seemingly hackish nature of manually giving it the name todo_ids[] and the method code calling sanitize_to_id(name). I just ran into this yesterday and I'm contemplating a patch.

提交回复
热议问题