Class: Redmine::Views::LabelledFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Redmine::Views::LabelledFormBuilder
- Includes:
- I18n
- Defined in:
- lib/redmine/views/labelled_form_builder.rb
Overview
Instance Method Summary collapse
- #check_box(field, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
-
#hours_field(field, options = {}) ⇒ Object
A field for entering hours value.
-
#label_for_field(field, options = {}) ⇒ Object
Returns a label tag for the given field.
- #select(field, choices, options = {}, html_options = {}) ⇒ Object
- #time_zone_select(field, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
Methods included from I18n
#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
Instance Method Details
#check_box(field, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
33 34 35 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 33 def check_box(field, ={}, checked_value="1", unchecked_value="0") label_for_field(field, ) + super(field, .except(:label), checked_value, unchecked_value).html_safe end |
#hours_field(field, options = {}) ⇒ Object
A field for entering hours value
46 47 48 49 50 51 52 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 46 def hours_field(field, ={}) # display the value before type cast when the entered value is not valid if @object.errors[field].blank? = .merge(:value => format_hours(@object.send field)) end text_field field, end |
#label_for_field(field, options = {}) ⇒ Object
Returns a label tag for the given field
55 56 57 58 59 60 61 62 63 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 55 def label_for_field(field, = {}) return ''.html_safe 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.html_safe, :class => (@object && @object.errors[field].present? ? "error" : nil), :for => (@object_name.to_s + "_" + field.to_s)) end |
#select(field, choices, options = {}, html_options = {}) ⇒ Object
37 38 39 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 37 def select(field, choices, = {}, = {}) label_for_field(field, ) + super(field, choices, , .except(:label)).html_safe end |
#time_zone_select(field, priority_zones = nil, options = {}, html_options = {}) ⇒ Object
41 42 43 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 41 def time_zone_select(field, priority_zones = nil, = {}, = {}) label_for_field(field, ) + super(field, priority_zones, , .except(:label)).html_safe end |