<% # headmin/filters # # ==== Options # * +url - Base url to send filter query to. Defaults to current URL # # ==== Examples # Basic version # <%= render "headmin/filters" do %#> # <%= render "headmin/filters/select", name: "color", options: ["red", "green", "blue"] %#> # <% end %#> # # With custom URL # <%= render "headmin/filters", url: admin_polls_path %#> action = local_assigns.has_key?(:url) ? url : request.path begin model = controller_name.singularize.capitalize.constantize rescue raise "Cannot find class!" end %> <%= form_with model: model.new, url: action, method: :get, data: {controller: "filters", filters_target: "form"} do |form| %> <%# Perform yield in order to capture content blocks, pass form so we can use headmin form inputs %> <%= yield(form) %> <% default_params.except("page").each do |name, value| %> <%= form.hidden_field name.to_sym, value: value %> <% end %>
<% if content_for?(:filters_menu) %>
<% end %>
<%= yield :filters_buttons %>
<%= yield :filters_templates %> <% end %> <% # Clears content blocks to make this view reusable content_for(:filters_search, flush: true) { concat(nil) } content_for(:filters_menu, flush: true) { concat(nil) } content_for(:filters_buttons, flush: true) { concat(nil) } content_for(:filters_templates, flush: true) { concat(nil) } %>