Class: ActionView::Helpers::InstanceTag

Inherits:
Object
  • Object
show all
Defined in:
lib/refinery/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/refinery/helpers/form_helper.rb', line 48

def to_label_tag(text = nil, options = {})
  options = options.stringify_keys
  name_and_id = options.dup
  add_default_name_and_id(name_and_id)
  options.delete("index")
  options["for"] ||= name_and_id["id"]
  if text.blank?
    content = method_name.humanize
    if object.class.respond_to?(:human_attribute_name)
      content = object.class.human_attribute_name(method_name)
    end
  else
    content = text.to_s
  end
  label_tag(name_and_id["id"], content, options)
end