Module: SimpleForm::Components::Labels

Included in:
Inputs::Base
Defined in:
lib/simple_form/components/labels.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/simple_form/components/labels.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#labelObject



26
27
28
# File 'lib/simple_form/components/labels.rb', line 26

def label
  @builder.label(label_target, label_text, label_html_options)
end

#label_html_optionsObject



39
40
41
42
43
# File 'lib/simple_form/components/labels.rb', line 39

def label_html_options
  label_options = html_options_for(:label, input_type, required_class)
  label_options[:for] = options[:input_html][:id] if options.key?(:input_html)
  label_options
end

#label_targetObject



35
36
37
# File 'lib/simple_form/components/labels.rb', line 35

def label_target
  attribute_name
end

#label_textObject



30
31
32
33
# File 'lib/simple_form/components/labels.rb', line 30

def label_text
  result = SimpleForm.label_text.call(raw_label_text, required_label_text)
  result.respond_to?(:html_safe) ? result.html_safe : result
end