Module: ZipSearch::ViewHelpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/zip_search/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#location_search_field(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/zip_search/view_helpers.rb', line 7

def location_search_field(options={})
  settings = {
    field: {
      placeholder: 'Filter by location...',
      class: ''
    },
    form: {
      url: request.url,
      method: :get,
      html: {
        class: '',
        style: ''
  } } }.deep_merge(options)
  if params.key?(:location_search) && params[:location_search].key?(:q)
    settings[:field][:class] << ' zipsearch-typeahead'
    settings[:field][:value] ||= params[:location_search][:q]
  end
  settings[:form][:html][:class] << ' location-search-form pull-left'
  # form_style = "margin:10px 6px 0 0;#{settings[:form][:html][:style]}"
  # settings[:form][:html][:style] = form_style
  render 'zip_search/locations/search_field', settings: settings
end