我有一个表格可以遍历每个学生,并使用单选按钮根据目标对他们进行评估。每个目标的得分应为 1-5。目前,除了单选按钮外,一切正常 - 在整个表单中一次只能选择一个单选按钮 - 即,如果目标一标记为 3,然后目标二标记为 4,则目标一变得没有标记。
代码如下:
evaluations - new.html.erb
...
<div class="holder2 round clear">
<%= form_for([@student, @evaluation]) do |f| %>
<% @subjects.each do |group, subjects| %>
<% subjects.each do |subject| %>
<h3><%= subject.name %></h3>
<%= render "goal_eval", :subject => subject, :f => f %>
<% end %>
<% end %>
<%= f.submit "Next student", :class => 'big_button round unselectable' %>
<% end %>
</div>
goal_eval partial
<table class="fixed">
<tbody>
<% subject.goals.each do |goal| %>
<tr class="<%= cycle("odd", "even", name: "goals")%>">
<td class="goal_row"><%= goal.goal %></td>
<td>
<% [1, 2, 3, 4, 5].each do |score| %>
<%= radio_button_tag :score, score, goal_id: goal.id, student_id: @student.id %>
<%= score %>
<% end %>
</td>
</tr>
<% end %>
<% reset_cycle("goals") %>
</tbody>
</table>