Class: Interview::SearchForm

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

Instance Attribute Summary

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Control

#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Control

Instance Method Details

#renderObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/interview/search_form.rb', line 4

def render
  object = find_attribute! :object
  return h.form_tag(h.polymorphic_path(object.class.model_name.plural, action: 'search'), method: :get, class: 'form-inline', role: 'form') do
    html = Builder::XmlMarkup.new(indent: 2)
    html.div do
      html.div class: 'form-group' do
        html << h.text_field_tag(:search, h.params[:search], class: 'form-control')
      end
      html.div class: 'form-group' do
        html << h.submit_tag('Suchen', :name => nil, class: 'form-control btn btn-primary') # todo: 'Suchen' ändern
      end
    end
    html.target!.html_safe
  end
end