Module: SimpleForm::Components::Labels

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



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

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) && options[:input_html].key?(:id)
  label_options
end

#label_targetObject



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

def label_target
  attribute_name
end

#label_textObject



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

def label_text
  SimpleForm.label_text.call(raw_label_text, required_label_text).html_safe
end