我有一個表單,它遍歷每個學生,並根據使用單選按鈕的目標對它們進行評估。每個目標的得分應爲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>
是完美工作,歡呼聲 - 我不得不改變它'比分_#{goal.id}',因爲subject_id是所有三個目標相同: '<%= radio_button_tag「比分_#{ goal.id}「,得分,goal_id:goal.id,student_id:@ student.id%>' – dax
是的,我的不好,編輯答案。很高興工作! – Intrepidd