Class: Nitro::OptionsControl
- Inherits:
-
AttributeControl
- Object
- Element
- Control
- AttributeControl
- Nitro::OptionsControl
- Defined in:
- lib/nitro/control/attribute/options.rb
Overview
Controls a Fixnum attribute that can contain discreet values (options).
Example
Pass a ‘reverse’ dictionary. Reverse to reuse the has for easy rendering of labels. Dictionary to allow for ordered keys.
PRIORITY_VALUES = Dictionary[
0, :trivial,
1, :minor,
2, :major,
3, :blocker
]
attr_accessor :priority, Fixnum, :control => :options, :options_data => PRIORITY_VALUES
Instance Attribute Summary
Attributes inherited from AttributeControl
Attributes included from ElementMixin
#_children, #_parent, #_text, #_view, #id
Instance Method Summary collapse
Methods inherited from AttributeControl
Methods included from XhtmlHelper
#date_select, #datetime_select, #hidden, #href_of, #js_popup, #link_to, #objects_to_options, #onclick_popup, #options, #popup, #submit, #time_select
Methods inherited from Element
Methods included from ElementMixin
#add_child, #close, #content, #initialize, #open, #render_children
Constructor Details
This class inherits a constructor from Nitro::AttributeControl
Instance Method Details
#render ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nitro/control/attribute/options.rb', line 26 def render style = @anno.control_style || self.class.style data = @anno[:options_data] %{ #{emit_label} <select id="#{@attribute}_ctl" name="#{@attribute}"> #{ :labels => data.values, :values => data.keys, :selected => value} </select> } end |