Class: Godmin::FormBuilders::FormBuilder

Inherits:
BootstrapForm::FormBuilder
  • Object
show all
Defined in:
lib/godmin/helpers/forms.rb

Instance Method Summary collapse

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, options = {})
  case association_type(attribute)
  when :belongs_to
    select "#{attribute}_id", association_collection_for_select(attribute), {}, data: { behavior: "select-box" }
  else
    input(attribute, options)
  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, options = {})
  text_field(attribute, options.deep_merge(
    value: datetime_value(attribute, options, :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, options = {})
  text_field(attribute, options.deep_merge(
    value: datetime_value(attribute, options, :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, options = {})
  case attribute_type(attribute)
  when :text
    text_area(attribute, options)
  when :boolean
    check_box(attribute, options)
  when :date
    date_field(attribute, options)
  when :datetime
    datetime_field(attribute, options)
  else
    text_field(attribute, options)
  end
end