Module: Rails::AddOns::SearchFormHelper

Defined in:
app/helpers/rails/add_ons/search_form_helper.rb

Defined Under Namespace

Classes: SearchFormBuilder, SearchableCollection

Instance Method Summary collapse

Instance Method Details

#search_form_for(collection, options = {}, &block) ⇒ Object

Example:

= search_form_for(@collection, url: collection_path, method: :get) do |f|
  = f.input :title_cont
  = f.input :product_number_cont
  = f.boolean :active_eq
  = f.submit nil, class: 'btn btn-primary'
  = f.reset  nil, class: 'btn btn-default'

13
14
15
16
# File 'app/helpers/rails/add_ons/search_form_helper.rb', line 13

def search_form_for(collection, options = {}, &block)
  wrapped_collection = SearchableCollection.new(collection, params[:q])
  simple_form_for(wrapped_collection, options.reverse_merge(as: :q, url: collection_path, method: :get, builder: SearchFormBuilder), &block)
end