<%= form_with model: [@tournament, @mat_assignment_rule] do |form| %>
<%= form.label :mat_id, "Select Mat" %>
<% if @available_mats.any? %> <%= form.collection_select :mat_id, @available_mats, :id, :name, { prompt: "Choose a Mat" } %> <% else %>

No mats are available. Please create a mat first.

<% end %>
<%= form.label :weight_classes, "Allowed Weight Classes" %>
<% if @tournament.weights.any? %> <% @tournament.weights.each do |weight| %>
<%= check_box_tag "mat_assignment_rule[weight_classes][]", weight.id, @mat_assignment_rule.weight_classes.map(&:to_i).include?(weight.id) %> <%= label_tag "mat_assignment_rule_weight_classes_#{weight.id}", weight.max %>
<% end %> <% else %>

No weight classes are available. Please create weight classes first.

<% end %>
<%= form.label :bracket_positions, "Allowed Bracket Positions" %>
<% if @unique_bracket_positions.present? %> <% @unique_bracket_positions.each do |position| %>
<%= check_box_tag "mat_assignment_rule[bracket_positions][]", position, @mat_assignment_rule.bracket_positions.include?(position) %> <%= label_tag "mat_assignment_rule_bracket_positions_#{position}", position %>
<% end %> <% else %>

No bracket positions are available. Please ensure matches have bracket positions set.

<% end %>
<%= form.label :rounds, "Allowed Rounds" %>
<% if @unique_rounds.present? %> <% @unique_rounds.each do |round| %>
<%= check_box_tag "mat_assignment_rule[rounds][]", round, @mat_assignment_rule.rounds.map(&:to_i).include?(round) %> <%= label_tag "mat_assignment_rule_rounds_#{round}", round %>
<% end %> <% else %>

No rounds are available. Please ensure matches have rounds set.

<% end %>
<%= form.submit 'Submit', class: "btn btn-success" %>
<% end %>