Class: Bureaucrat::Widgets::Input
- Defined in:
- lib/bureaucrat/widgets.rb
Direct Known Subclasses
Constant Summary
Constants included from Utils
Class Attribute Summary collapse
-
.input_type ⇒ Object
Returns the value of attribute input_type.
Attributes inherited from Widget
Class Method Summary collapse
-
.inherited(c) ⇒ Object
Copy data to the child class.
Instance Method Summary collapse
Methods inherited from Widget
#build_attrs, #has_changed?, #hidden?, id_for_label, #initialize, #initialize_copy, #media, #value_from_datahash
Methods included from Utils
conditional_escape, escape, flatatt, format_string, make_bool, make_float, mark_safe, pretty_name, security_hash
Constructor Details
This class inherits a constructor from Bureaucrat::Widgets::Widget
Class Attribute Details
.input_type ⇒ Object
Returns the value of attribute input_type.
160 161 162 |
# File 'lib/bureaucrat/widgets.rb', line 160 def input_type @input_type end |
Class Method Details
.inherited(c) ⇒ Object
Copy data to the child class
163 164 165 166 |
# File 'lib/bureaucrat/widgets.rb', line 163 def inherited(c) super(c) c.input_type = input_type.dup if input_type end |
Instance Method Details
#render(name, value, attrs = nil) ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/bureaucrat/widgets.rb', line 172 def render(name, value, attrs=nil) value ||= '' final_attrs = build_attrs(attrs, :type => self.class.input_type.to_s, :name => name.to_s) final_attrs[:value] = value.to_s unless value == '' mark_safe("<input#{flatatt(final_attrs)} />") end |