Class: Superform::Rails::Components::Label

Inherits:
Base
  • Object
show all
Defined in:
lib/superform/rails/components/label.rb

Instance Attribute Summary

Attributes inherited from Base

#dom, #field

Instance Method Summary collapse

Methods inherited from Base

#focus, #initialize

Constructor Details

This class inherits a constructor from Superform::Rails::Components::Base

Instance Method Details

#field_attributesObject



10
11
12
# File 'lib/superform/rails/components/label.rb', line 10

def field_attributes
  { for: dom.id }
end

#label_textObject



14
15
16
# File 'lib/superform/rails/components/label.rb', line 14

def label_text
  field.key.to_s.titleize
end

#view_template(&content) ⇒ Object



5
6
7
8
# File 'lib/superform/rails/components/label.rb', line 5

def view_template(&content)
  content ||= Proc.new { label_text }
  label(**attributes, &content)
end