Class: TabularFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- TabularFormBuilder
- Includes:
- Redmine::I18n
- Defined in:
- lib/tabular_form_builder.rb
Instance Method Summary collapse
-
#initialize(object_name, object, template, options, proc) ⇒ TabularFormBuilder
constructor
A new instance of TabularFormBuilder.
-
#label_for_field(field, options = {}) ⇒ Object
Returns a label tag for the given field.
- #select(field, choices, options = {}, html_options = {}) ⇒ Object
Methods included from Redmine::I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Constructor Details
#initialize(object_name, object, template, options, proc) ⇒ TabularFormBuilder
Returns a new instance of TabularFormBuilder.
23 24 25 26 |
# File 'lib/tabular_form_builder.rb', line 23 def initialize(object_name, object, template, , proc) set_language_if_valid .delete(:lang) super end |
Instance Method Details
#label_for_field(field, options = {}) ⇒ Object
Returns a label tag for the given field
42 43 44 45 46 47 48 49 50 |
# File 'lib/tabular_form_builder.rb', line 42 def label_for_field(field, = {}) return '' if .delete(:no_label) text = [:label].is_a?(Symbol) ? l([:label]) : [:label] text ||= l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym) text += @template.content_tag("span", " *", :class => "required") if .delete(:required) @template.content_tag("label", text, :class => (@object && @object.errors[field] ? "error" : nil), :for => (@object_name.to_s + "_" + field.to_s)) end |
#select(field, choices, options = {}, html_options = {}) ⇒ Object
37 38 39 |
# File 'lib/tabular_form_builder.rb', line 37 def select(field, choices, = {}, = {}) label_for_field(field, ) + super end |