Module: JqueryUiForm::Helpers::LabelHelper

Included in:
FormBuilder
Defined in:
lib/jquery_ui_form/helpers/label_helper.rb

Instance Method Summary collapse

Instance Method Details

#label(method, text = nil, options = {}) ⇒ Object

include ActionView::Helpers::FormHelper



6
7
8
9
10
11
# File 'lib/jquery_ui_form/helpers/label_helper.rb', line 6

def label(method, text = nil, options = {})
  
  text, options = label_text(method, text, options)
  super(method,"#{text}:".html_safe, options)
  
end

#label_text(method, text, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jquery_ui_form/helpers/label_helper.rb', line 13

def label_text(method, text, options={})
  if text.is_a?(Hash)
    options.merge!(text)
    text = nil
  end
  text = options.delete(:label) if text.blank?
  if text.blank?
    if use_i18n
      text = I18n.t("#{@object_name.to_s.downcase}.#{method.to_s.downcase}",:scope => [:activerecord, :attributes])
    else
      text = method.to_s.humanize
    end
  end
  if options.delete(:required)
    text << (required_string.is_a?(Proc) ? required_string.call : required_string)
  end
  [text, options]
end