Module: ActiveAdmin::Filters::ViewHelper
- Defined in:
- lib/active_admin/filters/forms.rb
Overview
This module is included into the view
Instance Method Summary collapse
-
#active_admin_filters_form_for(search, filters, options = {}) ⇒ Object
Helper method to render a filter form.
Instance Method Details
#active_admin_filters_form_for(search, filters, options = {}) ⇒ Object
Helper method to render a filter form
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/active_admin/filters/forms.rb', line 57 def active_admin_filters_form_for(search, filters, = {}) defaults = { :builder => ActiveAdmin::Filters::FormBuilder, :url => collection_path, :html => {:class => 'filter_form'} } required = { :html => {:method => :get}, :as => :q } = defaults.deep_merge().deep_merge(required) form_for search, do |f| filters.group_by{ |o| o[:attribute] }.each do |attribute, array| opts = array.last # grab last-defined `filter` call from DSL should = opts.delete(:if) || proc{ true } shouldnt = opts.delete(:unless) || proc{ false } if call_method_or_proc_on(self, should) && !call_method_or_proc_on(self, shouldnt) f.filter attribute, opts end end = content_tag :div, :class => "buttons" do f.submit(I18n.t('active_admin.filters.buttons.filter')) + link_to(I18n.t('active_admin.filters.buttons.clear'), '#', :class => 'clear_filters_btn') + (params, :except => [:q, :page]) end f.form_buffers.last + end end |