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
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, included, #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
35 36 37 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 35 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
48 49 50 51 52 53 54 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 48 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
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 57 def label_for_field(field, = {}) return ''.html_safe if .delete(:no_label) text = [:label].is_a?(Symbol) ? l([:label]) : [:label] text ||= @object.class.human_attribute_name(field) 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
39 40 41 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 39 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
43 44 45 |
# File 'lib/redmine/views/labelled_form_builder.rb', line 43 def time_zone_select(field, priority_zones = nil, = {}, = {}) label_for_field(field, ) + super(field, priority_zones, , .except(:label)).html_safe end |