Class: Interview::SearchForm

Inherits:
Control
  • Object
show all
Includes:
NestedBuildable
Defined in:
lib/interview/controls/search_form.rb

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from NestedBuildable

#create_nested_builder, #render_nested_builder

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Control

Instance Attribute Details

#objectObject

Returns the value of attribute object.



6
7
8
# File 'lib/interview/controls/search_form.rb', line 6

def object
  @object
end

Instance Method Details

#build(b) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/interview/controls/search_form.rb', line 8

def build(b)
  object = @object || find_attribute!(:object)
  b << h.form_tag(h.polymorphic_path(object.class.model_name.plural, action: 'search'), method: :get, class: 'form-inline', role: 'form') do
    create_nested_builder(b)
    b.section do
      b.section html_class: 'form-group' do
        b << h.text_field_tag(:search, h.params[:search], class: 'form-control')
      end
      b.section html_class: 'form-group' do
        b << h.submit_tag('Suchen', :name => nil, class: 'form-control btn btn-primary') # todo: 'Suchen' ändern
      end
    end
    render_nested_builder(b)
  end
end