Class: FormFu::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- FormFu::FormBuilder
- Defined in:
- lib/form_fu/form_builder.rb
Overview
A form builder that produces tableless, lined-up forms.
Instance Method Summary collapse
-
#date_select(field, options = {}, &block) ⇒ Object
wrap the date_select helper.
-
#error_messages(object_name = nil) ⇒ Object
create an error messages helper.
-
#image_submit(img_path, options = {}) ⇒ Object
create a image_submit helper.
-
#radio_group(field, choices, options = {}, &block) ⇒ Object
create a radio group helper that works very similarly to the select helper.
- #select(field, choices, options = {}, &block) ⇒ Object
-
#select_input ⇒ Object
wrap the select helper.
-
#submit(value = "Submit", options = {}) ⇒ Object
create a submit helper.
- #text_area(field, options = {}, &block) ⇒ Object
- #text_area_input ⇒ Object
Instance Method Details
#date_select(field, options = {}, &block) ⇒ Object
wrap the date_select helper
22 23 24 |
# File 'lib/form_fu/form_builder.rb', line 22 def date_select(field, ={}, &block) format_with_label(field, .merge(:field_type => "date"), super(field, ()), &block) end |
#error_messages(object_name = nil) ⇒ Object
create an error messages helper
69 70 71 |
# File 'lib/form_fu/form_builder.rb', line 69 def (object_name = nil) @template. object_name || @object_name end |
#image_submit(img_path, options = {}) ⇒ Object
create a image_submit helper
64 65 66 |
# File 'lib/form_fu/form_builder.rb', line 64 def image_submit(img_path, = {}) @template.image_submit_tag(img_path, ) end |
#radio_group(field, choices, options = {}, &block) ⇒ Object
create a radio group helper that works very similarly to the select helper
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/form_fu/form_builder.rb', line 27 def radio_group(field, choices, ={}, &block) # handle special cases if choices == :boolean choices = [["True", "true"], ["False", "false"]] elsif choices == :yes_no choices = [["Yes", "yes"], ["No", "no"]] elsif choices.class != Array choices = [] end # build radio choices html choices_html = "" choices.each do |key, value| radio_html = (field, value)+key # wrap radio html in a label (for easier selection) choices_html << @template.content_tag(:label, radio_html, :class => "radio-option") end # wrap the radio-group with a label format_with_label(field, .merge(:field_type => "radio-group"), choices_html, &block) end |
#select(field, choices, options = {}, &block) ⇒ Object
53 54 55 56 |
# File 'lib/form_fu/form_builder.rb', line 53 def select(field, choices, ={}, &block) = .delete(:html) || {} format_with_label(field, .merge(:field_type => "select"), super(field, choices, , ), &block) end |
#select_input ⇒ Object
wrap the select helper
52 |
# File 'lib/form_fu/form_builder.rb', line 52 alias :select_input :select |
#submit(value = "Submit", options = {}) ⇒ Object
create a submit helper
59 60 61 |
# File 'lib/form_fu/form_builder.rb', line 59 def submit(value = "Submit", = {}) @template.submit_tag(value, ) end |
#text_area(field, options = {}, &block) ⇒ Object
17 18 19 |
# File 'lib/form_fu/form_builder.rb', line 17 def text_area(field, = {}, &block) format_with_label(field, .merge(:field_type => "text_area"), super(field, ()), &block) end |
#text_area_input ⇒ Object
16 |
# File 'lib/form_fu/form_builder.rb', line 16 alias :text_area_input :text_area |