Class: KonoUtils::ApplicationHelper::BaseSearchFormWrapper

Inherits:
Struct
  • Object
show all
Defined in:
lib/kono_utils/application_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



99
100
101
# File 'lib/kono_utils/application_helper.rb', line 99

def attributes
  @attributes
end

#current_userObject

Returns the value of attribute current_user

Returns:

  • (Object)

    the current value of current_user



99
100
101
# File 'lib/kono_utils/application_helper.rb', line 99

def current_user
  @current_user
end

#formtastic_formObject

Returns the value of attribute formtastic_form

Returns:

  • (Object)

    the current value of formtastic_form



99
100
101
# File 'lib/kono_utils/application_helper.rb', line 99

def formtastic_form
  @formtastic_form
end

Instance Method Details

#fields_builder(cfgs = {field_options: {}}) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/kono_utils/application_helper.rb', line 101

def fields_builder(cfgs={field_options: {}})
  form_buffer = ActiveSupport::SafeBuffer.new

  self.attributes.each do |field|

    form_options = field.form_options
    if form_options.is_a?(Proc)
      form_options = form_options.call(current_user, self.formtastic_form)
    end

    form_buffer << self.formtastic_form.input(field.field, cfgs[:field_options].merge(form_options))
  end

  form_buffer
end