Module: Decidim::FiltersHelper

Overview

Helper that provides a single method to create filter resource forms

Constant Summary

Constants included from IconHelper

IconHelper::DEFAULT_RESOURCE_TYPE_ICONS

Instance Method Summary collapse

Methods included from IconHelper

#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key, #text_with_resource_icon

Methods included from LayoutHelper

#_icon_classes, #apple_favicon, #application_path, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #organization_colors, #role

Methods included from TooltipHelper

#with_tooltip

Methods included from ModalHelper

#decidim_modal

Instance Method Details

#filter_form_for(filter, url = url_for, html_options = {}) ⇒ Object

This method wraps everything in a div with class filters and calls the form_for helper with a custom builder

filter - A filter object url - A String with the URL to post the from. Self URL by default. html_options - Extra HTML options to be passed to form_for block - A block to be called with the form builder

Returns the filter resource form wrapped in a div



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'decidim-core/app/helpers/decidim/filters_helper.rb', line 17

def filter_form_for(filter, url = url_for, html_options = {})
  form_for(
    filter,
    namespace: filter_form_namespace,
    builder: FilterFormBuilder,
    url:,
    as: :filter,
    method: :get,
    remote: true,
    html: { id: nil }.merge(html_options)
  ) do |form|
    inner = []
    inner << hidden_field_tag("per_page", params[:per_page], id: nil) if params[:per_page]
    inner << capture { yield form }
    inner.join.html_safe
  end
end