Class: FieldableForm::DropDown
- Defined in:
- lib/fieldable_form/drop_down.rb
Constant Summary
Constants inherited from Field
Instance Method Summary collapse
- #include_blank ⇒ Object
- #include_blank=(value) ⇒ Object
- #items ⇒ Object
- #items=(value) ⇒ Object
-
#render_method ⇒ Object
Overrides.
-
#render_options ⇒ Object
Overrides.
- #required ⇒ Object
- #required=(value) ⇒ Object
-
#validators ⇒ Object
Overrides.
-
#view_partial_name ⇒ Object
Overrides.
Methods inherited from Field
Instance Method Details
#include_blank ⇒ Object
42 43 44 |
# File 'lib/fieldable_form/drop_down.rb', line 42 def include_blank ['include_blank'] end |
#include_blank=(value) ⇒ Object
46 47 48 49 |
# File 'lib/fieldable_form/drop_down.rb', line 46 def include_blank=(value) if ['include_blank'] != value ['include_blank'] = value end |
#items ⇒ Object
51 52 53 |
# File 'lib/fieldable_form/drop_down.rb', line 51 def items ['items'] end |
#items=(value) ⇒ Object
55 56 57 58 |
# File 'lib/fieldable_form/drop_down.rb', line 55 def items=(value) if ['items'] != value ['items'] = value end |
#render_method ⇒ Object
Overrides
7 8 9 |
# File 'lib/fieldable_form/drop_down.rb', line 7 def render_method :select end |
#render_options ⇒ Object
Overrides
12 13 14 15 16 17 18 19 |
# File 'lib/fieldable_form/drop_down.rb', line 12 def items_array = items.split(',').map(&:strip) if include_blank == '1' items_array.map! { |i| [i, i] } items_array.first[1] = nil end [name, items_array] end |
#required ⇒ Object
33 34 35 |
# File 'lib/fieldable_form/drop_down.rb', line 33 def required ['required'] end |
#required=(value) ⇒ Object
37 38 39 40 |
# File 'lib/fieldable_form/drop_down.rb', line 37 def required=(value) if ['required'] != value ['required'] = value end |
#validators ⇒ Object
Overrides
27 28 29 30 31 |
# File 'lib/fieldable_form/drop_down.rb', line 27 def validators validators = [] validators << ActiveModel::Validations::PresenceValidator.new(:attributes => name) if required == '1' validators end |
#view_partial_name ⇒ Object
Overrides
22 23 24 |
# File 'lib/fieldable_form/drop_down.rb', line 22 def view_partial_name 'drop_down' end |