Class: Godmin::FormBuilders::FormBuilder
- Inherits:
-
BootstrapForm::FormBuilder
- Object
- BootstrapForm::FormBuilder
- Godmin::FormBuilders::FormBuilder
- Defined in:
- lib/godmin/helpers/forms.rb
Instance Method Summary collapse
- #association(attribute, options = {}) ⇒ Object
- #date_field(attribute, options = {}) ⇒ Object
- #datetime_field(attribute, options = {}) ⇒ Object
- #input(attribute, options = {}) ⇒ Object
Instance Method Details
#association(attribute, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/godmin/helpers/forms.rb', line 27 def association(attribute, = {}) case association_type(attribute) when :belongs_to select "#{attribute}_id", association_collection_for_select(attribute), {}, data: { behavior: "select-box" } else input(attribute, ) end end |
#date_field(attribute, options = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/godmin/helpers/forms.rb', line 36 def date_field(attribute, = {}) text_field(attribute, .deep_merge( value: datetime_value(attribute, , :datepicker), data: { behavior: "datepicker" } )) end |
#datetime_field(attribute, options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/godmin/helpers/forms.rb', line 43 def datetime_field(attribute, = {}) text_field(attribute, .deep_merge( value: datetime_value(attribute, , :datetimepicker), data: { behavior: "datetimepicker" } )) end |
#input(attribute, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/godmin/helpers/forms.rb', line 12 def input(attribute, = {}) case attribute_type(attribute) when :text text_area(attribute, ) when :boolean check_box(attribute, ) when :date date_field(attribute, ) when :datetime datetime_field(attribute, ) else text_field(attribute, ) end end |