Class: TabularFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- TabularFormBuilder
- Includes:
- Redmine::I18n
- Defined in:
- lib/tabular_form_builder.rb
Instance Method Summary
-
- (TabularFormBuilder) initialize(object_name, object, template, options, proc)
constructor
A new instance of TabularFormBuilder.
-
- (Object) label_for_field(field, options = {})
Returns a label tag for the given field.
- - (Object) select(field, choices, options = {}, html_options = {})
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
- (TabularFormBuilder) initialize(object_name, object, template, options, proc)
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
- (Object) label_for_field(field, options = {})
Returns a label tag for the given field
43 44 45 46 47 48 49 50 51 |
# File 'lib/tabular_form_builder.rb', line 43 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 |
- (Object) select(field, choices, options = {}, html_options = {})
38 39 40 |
# File 'lib/tabular_form_builder.rb', line 38 def select(field, choices, = {}, = {}) label_for_field(field, ) + super end |