<%= form_with url: form_url, method: form_method, local: true do |f| %> <% ScoringCriterium.grouped_by_category.each do |category, criteria| %>
<%= category.titlecase %> <% criteria.each do |criterium| %> <% current_score = existing_scores.find { |score| score.scoring_criterium_id == criterium.id } %>

<%= number_field_tag "scores[#{criterium.id}][value]", current_score&.value, in: 1..5, required: true, placeholder: "Score (1-5)" %> <%= label_tag "scores[#{criterium.id}][value]", criterium.name.capitalize %>

<% end %>
<% end %> <%= f.submit submit_text %> <% end %>