Module: Decidim::Admin::SearchFormHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/decidim/admin/search_form_helper.rb

Overview

Overrides some methods from Ransack::Helpers::FormHelper to fix the search user interfaces within Decidim.

Instance Method Summary collapse

Instance Method Details

#search_form_for(record, options = {}) ⇒ Object

Provide the correct builder option for the admin search forms. Otherwise they would be generated using Ransack::Helpers::FormHelper which does not provide all the same features that the Decidim form builders, such as datetime pickers.



12
13
14
15
16
17
# File 'app/helpers/decidim/admin/search_form_helper.rb', line 12

def search_form_for(record, options = {}, &)
  options[:builder] ||= SearchFormBuilder
  options[:url] = url_for(params.to_unsafe_h.except("locale", :locale).merge(locale: nil)) if options[:url].blank?

  super
end


19
20
21
22
23
24
25
# File 'app/helpers/decidim/admin/search_form_helper.rb', line 19

def sort_link(search_object, attribute, *args, &)
  options = args.extract_options!
  options = options.merge(params: sort_link_params)
  args << options

  super
end