Class: GenericFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- GenericFormBuilder
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/generic_form_builder.rb
Instance Method Summary collapse
- #buttons(options = {}) ⇒ Object
- #check_box(field, options = {}) ⇒ Object
- #collection_select(field, collection, value_method, name_method, options = {}, html_options = {}) ⇒ Object
- #radio_button(field, value, options = {}) ⇒ Object
- #select(field, collection, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#buttons(options = {}) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/generic_form_builder.rb', line 62 def ( = {}) = content_tag(:button, content_tag(:span, [:submit_text] || 'Save'), :type => 'submit') << link_to('Cancel', [:cancel_link], :class => 'cancel button') if [:cancel_link] content_tag(:div, , :class => 'actions') end |
#check_box(field, options = {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/generic_form_builder.rb', line 48 def check_box(field, = {}) return super if [:default_builder] label_text = [:label] || field.to_s.humanize note = note_html([:note]) content_tag(:p, label(field, super + " #{label_text} #{errors_text(field)}".try(:html_safe) + note, :class => 'checkbox')) end |
#collection_select(field, collection, value_method, name_method, options = {}, html_options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/generic_form_builder.rb', line 41 def collection_select(field, collection, value_method, name_method, = {}, = {}) return super(field, collection, value_method, name_method) if [:default_builder] label_text = [:label] || field.to_s.humanize note = note_html([:note]) content_tag(:p, label(field, "#{label_text} #{errors_text(field)}".try(:html_safe)) + note + super(field, collection, value_method, name_method)) end |
#radio_button(field, value, options = {}) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/generic_form_builder.rb', line 55 def (field, value, = {}) return super if [:default_builder] label_text = .delete(:label) || field.to_s.humanize tag_type = .delete(:tag_type) || :li content_tag(tag_type, label("#{field}_#{value.to_s.downcase.gsub(' ', '_')}", super + " #{label_text} #{errors_text(field)}".try(:html_safe), :class => 'radio', :onclick => "")) end |
#select(field, collection, options = {}, html_options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generic_form_builder.rb', line 30 def select(field, collection, = {}, = {}) return super if [:default_builder] label_text = [:label] || field.to_s.humanize note = note_html([:note]) = {} if any_errors?(field) .merge!('class' => 'errors') end content_tag(:p, label(field, "#{label_text} #{errors_text(field)}".try(:html_safe)) + note + super, ) end |