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
wrap the select helper.
-
#submit(value = "Submit", options = {}) ⇒ Object
create a submit helper.
- #text_area(field, options = {}, &block) ⇒ Object
Instance Method Details
#date_select(field, options = {}, &block) ⇒ Object
wrap the date_select helper
20 21 22 |
# File 'lib/form_fu/form_builder.rb', line 20 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
66 67 68 |
# File 'lib/form_fu/form_builder.rb', line 66 def (object_name = nil) @template. object_name || @object_name end |
#image_submit(img_path, options = {}) ⇒ Object
create a image_submit helper
61 62 63 |
# File 'lib/form_fu/form_builder.rb', line 61 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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/form_fu/form_builder.rb', line 25 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
wrap the select helper
50 51 52 53 |
# File 'lib/form_fu/form_builder.rb', line 50 def select(field, choices, ={}, &block) = .delete(:html) || {} format_with_label(field, .merge(:field_type => "select"), super(field, choices, , ), &block) end |
#submit(value = "Submit", options = {}) ⇒ Object
create a submit helper
56 57 58 |
# File 'lib/form_fu/form_builder.rb', line 56 def submit(value = "Submit", = {}) @template.submit_tag(value, ) end |
#text_area(field, options = {}, &block) ⇒ Object
15 16 17 |
# File 'lib/form_fu/form_builder.rb', line 15 def text_area(field, = {}, &block) format_with_label(field, .merge(:field_type => "text_area", :preserve => true), super(field, ()), &block) end |