Module: Presenting::FormHelpers

Defined in:
lib/presenting/form_helpers.rb

Instance Method Summary collapse

Instance Method Details

#present(field) ⇒ Object



2
3
4
# File 'lib/presenting/form_helpers.rb', line 2

def present(field)
  send("present_#{field.type}_input", field)
end

#present_boolean_input(field) ⇒ Object



26
27
28
# File 'lib/presenting/form_helpers.rb', line 26

def present_boolean_input(field)
  check_box field.name
end

#present_dropdown_input(field) ⇒ Object Also known as: present_select_input



30
31
32
# File 'lib/presenting/form_helpers.rb', line 30

def present_dropdown_input(field)
  view.select_tag "#{object_name}[#{field.name}]", view.options_for_select(field.type_options, object.send(field.name))
end

#present_hidden_input(field) ⇒ Object



14
15
16
# File 'lib/presenting/form_helpers.rb', line 14

def present_hidden_input(field)
  hidden_field field.name, :value => field.value_from(object)
end

#present_multi_select_input(field) ⇒ Object



35
36
37
# File 'lib/presenting/form_helpers.rb', line 35

def present_multi_select_input(field)
  view.select_tag "#{object_name}[#{field.name}][]", view.options_for_select(field.type_options, object.send(field.name)), :multiple => true
end

#present_password_input(field) ⇒ Object



22
23
24
# File 'lib/presenting/form_helpers.rb', line 22

def present_password_input(field)
  password_field field.name
end

#present_radios_input(field) ⇒ Object



39
40
41
42
43
44
# File 'lib/presenting/form_helpers.rb', line 39

def present_radios_input(field)
  field.type_options.collect do |(display, value)|
    label("#{field.name}_#{value}", display) +
    radio_button(field.name, value)
  end.join.html_safe
end

#present_readonly_input(field) ⇒ Object



6
7
8
# File 'lib/presenting/form_helpers.rb', line 6

def present_readonly_input(field)
  text_field field.name, :disabled => true, :value => field.value_from(object)
end

#present_string_input(field) ⇒ Object



10
11
12
# File 'lib/presenting/form_helpers.rb', line 10

def present_string_input(field)
  text_field field.name, :value => field.value_from(object)
end

#present_text_input(field) ⇒ Object



18
19
20
# File 'lib/presenting/form_helpers.rb', line 18

def present_text_input(field)
  text_area field.name, :value => field.value_from(object)
end