Filter

<%= form_for @changeset, Routes.filter_path(@conn, :update, @changeset.data.id), fn form -> %>
<%= select form, :mode, [{"Accept", :accept}, {"Reject", :reject}], class: "form-control" %>
<%= number_input form, :score, class: "form-control" %>

Rules

<%= inputs_for form, :rules, fn p -> %> <% end %>
Property Mode Param Weight
<%= select p, :property, [{"URL", :url}, {"Title", :title}, {"Author", :author}, {"Content", :content}], class: "form-control" %> <%= select p, :mode, [{"contains", :contains_string}, {"matches regex", :matches_regex}], class: "form-control" %> <%= text_input p, :param, class: "form-control" %> <%= number_input p, :weight, class: "form-control" %> <%# when nesting form tags, the first nested one seems to get removed %> <%# not the first nested one in each row, but the first nested one overall %> <%# so we include a dummy form with display: none that gets stripped from the first row %> <%# but is present and invisible in subsequent rows %>
<%= form_tag Routes.filter_path(@conn, :remove_rule, @changeset.data.id, [rule_id: p.data.id]), method: :post do %> <%= submit "Delete", class: "btn btn-danger" %> <% end %>
<%= form_tag Routes.filter_path(@conn, :add_rule, @changeset.data.id), method: :post do %> <%= submit "Add Rule", class: "btn btn-secondary" %> <% end %>
<%= submit "Update Filter", class: "btn btn-primary" %>
<% end %>