Class: HtmlGrid::Input

Inherits:
NamedComponent show all
Defined in:
lib/htmlgrid/input.rb

Direct Known Subclasses

InputCheckbox, InputRadio, InputText, Pass, Textarea

Constant Summary

Constants inherited from Component

Component::CSS_CLASS, Component::CSS_ID, Component::HTML_ATTRIBUTES, Component::HTTP_HEADERS, Component::LABEL

Instance Attribute Summary

Attributes inherited from NamedComponent

#name

Attributes inherited from Component

#attributes, #dojo_tooltip, #label, #model, #value

Instance Method Summary collapse

Methods inherited from NamedComponent

#data_origin, #error?, #initialize

Methods inherited from Component

#_to_html, #autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_dynamic_html, #dojo_parse_on_load, #dojo_tag, #dojo_title=, #dynamic_html, #escape, #escape_symbols, #formname, #http_headers, #initialize, #label?, #onclick=, #onload=, #onsubmit=, #set_attribute, #tabindex=

Constructor Details

This class inherits a constructor from HtmlGrid::NamedComponent

Instance Method Details

#initObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/htmlgrid/input.rb', line 31

def init
  super
  @attributes["name"] = @name.to_s
  value = nil
  if @model.respond_to?(@name)
    value = @model.send(@name)
  end
  if value.nil? \
    && @session.respond_to?(:user_input)
    value = @session.user_input(@name)
  end
  if value.nil? && autofill? \
    && @session.respond_to?(:get_cookie_input)
    value = @session.get_cookie_input(@name)
  end
  if value.is_a? RuntimeError
    value = value.value
  end
  self.value = value
end

#to_html(context) ⇒ Object



57
58
59
# File 'lib/htmlgrid/input.rb', line 57

def to_html(context)
  context.input(@attributes)
end

#value=(value) ⇒ Object



52
53
54
55
# File 'lib/htmlgrid/input.rb', line 52

def value=(value)
  @attributes.store("value", value.to_s)
  @value = value
end