Class: Dima::Html::SimpleField
- Defined in:
- lib/dima/html/field.rb
Overview
Simple field has a name associated with it. Using this name we can associate values from a model.
Direct Known Subclasses
ArrayField, BooleanField, DateField, EmailField, IconField, NumberField, SelectField, TextField, WebField
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#lambda ⇒ Object
Returns the value of attribute lambda.
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#readonly ⇒ Object
Returns the value of attribute readonly.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Field
#after, #align, #before, #edit, #form, #has_errors, #hint, #label, #required, #tooltip, #url
Instance Method Summary collapse
-
#<<(v) ⇒ Object
Initialize this field from a model.
- #>>(v) ⇒ Object
- #empty? ⇒ Boolean
- #main_content_node ⇒ Object
- #readonly? ⇒ Boolean
Methods inherited from Field
#after_node, #before_node, #edit?, #empty_node, #label_node, #options, #to_n, #url_node, #val, #val=, #validate, #value_node
Methods included from Init
Methods inherited from Element
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
149 150 151 |
# File 'lib/dima/html/field.rb', line 149 def height @height end |
#klass ⇒ Object
Returns the value of attribute klass.
152 153 154 |
# File 'lib/dima/html/field.rb', line 152 def klass @klass end |
#lambda ⇒ Object
Returns the value of attribute lambda.
148 149 150 |
# File 'lib/dima/html/field.rb', line 148 def lambda @lambda end |
#model ⇒ Object
Returns the value of attribute model.
151 152 153 |
# File 'lib/dima/html/field.rb', line 151 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
147 148 149 |
# File 'lib/dima/html/field.rb', line 147 def name @name end |
#readonly ⇒ Object
Returns the value of attribute readonly.
150 151 152 |
# File 'lib/dima/html/field.rb', line 150 def readonly @readonly end |
#width ⇒ Object
Returns the value of attribute width.
149 150 151 |
# File 'lib/dima/html/field.rb', line 149 def width @width end |
Instance Method Details
#<<(v) ⇒ Object
Initialize this field from a model.
The field can be initialized from a hash too.
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/dima/html/field.rb', line 157 def << (v) if v and v.is_a?(Hash) update_from_hash(v) else self.model = v if self.lambda self.val = self.lambda.call(v) rescue nil elsif self.name self.val = Dima::Utils.get(v, self.name) rescue nil end end end |
#>>(v) ⇒ Object
170 171 172 |
# File 'lib/dima/html/field.rb', line 170 def >> (v) Dima::Utils.set(v, self.name, self.val) if self.name and not self.readonly? end |
#empty? ⇒ Boolean
180 181 182 |
# File 'lib/dima/html/field.rb', line 180 def empty? Dima::Utils.empty?(self.val) end |
#main_content_node ⇒ Object
174 175 176 177 178 |
# File 'lib/dima/html/field.rb', line 174 def main_content_node n = simple_value_node n.add_class(self.klass) if self.klass n end |
#readonly? ⇒ Boolean
184 185 186 |
# File 'lib/dima/html/field.rb', line 184 def readonly? self.readonly end |