Class: Shoehorn::Components::Form::InputField

Inherits:
Shoehorn::Components::Form show all
Defined in:
lib/shoehorn/components/form/input_field.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#default_options, #options, #output_buffer

Instance Method Summary collapse

Constructor Details

#initialize(object_name, method, input_html, options = {}) ⇒ InputField

Returns a new instance of InputField.



5
6
7
8
9
# File 'lib/shoehorn/components/form/input_field.rb', line 5

def initialize(object_name, method, input_html, options = {})
  super(options)
  @input_html = input_html
  @label_html = Label.new(object_name, method, options) if options[:label] || options[:label_text]
end

Instance Attribute Details

#input_htmlObject

Returns the value of attribute input_html.



3
4
5
# File 'lib/shoehorn/components/form/input_field.rb', line 3

def input_html
  @input_html
end

#label_htmlObject

Returns the value of attribute label_html.



3
4
5
# File 'lib/shoehorn/components/form/input_field.rb', line 3

def label_html
  @label_html
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shoehorn/components/form/input_field.rb', line 11

def to_s
  output_buffer << (:div, :class => 'control-group') do
    html = ''
    html << label_html.to_s
    html << (:div, :class => 'controls') do
      build_input_wrapper << build_help_text
    end
    html.html_safe
  end
  super
end