module SimpleForm::Components::Labels

Public Instance Methods

label() click to toggle source
# File lib/simple_form/components/labels.rb, line 24
def label
  if generate_label_for_attribute?
    @builder.label(label_target, label_text, label_html_options)
  else
    template.label_tag(nil, label_text, label_html_options)
  end
end
label_html_options() click to toggle source
# File lib/simple_form/components/labels.rb, line 40
def label_html_options
  label_html_classes = SimpleForm.additional_classes_for(:label) {
    [input_type, required_class, SimpleForm.label_class].compact
  }

  label_options = html_options_for(:label, label_html_classes)
  if options.key?(:input_html) && options[:input_html].key?(:id)
    label_options[:for] = options[:input_html][:id]
  end
  label_options
end
label_target() click to toggle source
# File lib/simple_form/components/labels.rb, line 36
def label_target
  attribute_name
end
label_text() click to toggle source
# File lib/simple_form/components/labels.rb, line 32
def label_text
  SimpleForm.label_text.call(raw_label_text, required_label_text).strip.html_safe
end

Protected Instance Methods

generate_label_for_attribute?() click to toggle source
# File lib/simple_form/components/labels.rb, line 74
def generate_label_for_attribute?
  true
end