Class: Presentation::Form::Field
- Inherits:
-
Object
- Object
- Presentation::Form::Field
- Includes:
- Presenting::Configurable
- Defined in:
- lib/presentation/form.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
the display label of the field.
-
#name ⇒ Object
the parameter name of the field.
-
#type ⇒ Object
the widget type for the field.
-
#type_options ⇒ Object
unrestricted options storage for the widget type.
-
#value ⇒ Object
where the value for this field comes from.
Instance Method Summary collapse
-
#value_from(obj) ⇒ Object
:nodoc:.
Methods included from Presenting::Configurable
Instance Attribute Details
#label ⇒ Object
the display label of the field
107 108 109 |
# File 'lib/presentation/form.rb', line 107 def label @label ||= name.to_s.titleize end |
#name ⇒ Object
the parameter name of the field
113 114 115 |
# File 'lib/presentation/form.rb', line 113 def name @name end |
#type ⇒ Object
the widget type for the field. use type_options to pass arguments to the widget.
136 137 138 |
# File 'lib/presentation/form.rb', line 136 def type @type ||= :string end |
#type_options ⇒ Object
unrestricted options storage for the widget type. this could be a list of options for a select, or extra configuration for a calendar widget.
142 143 144 |
# File 'lib/presentation/form.rb', line 142 def @type_options end |
#value ⇒ Object
where the value for this field comes from.
-
String: a fixed value
-
Symbol: a method on the record (no arguments)
-
Proc: a custom block that accepts the record as an argument
119 120 121 |
# File 'lib/presentation/form.rb', line 119 def value @value ||= name.to_sym end |
Instance Method Details
#value_from(obj) ⇒ Object
:nodoc:
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/presentation/form.rb', line 124 def value_from(obj) #:nodoc: case value when Symbol obj.send(value) when String value when Proc value.call(obj) end end |