Class: Superform::Rails::Components::ButtonComponent

Inherits:
FieldComponent show all
Defined in:
lib/superform/rails.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#dom, #field

Instance Method Summary collapse

Methods inherited from BaseComponent

#focus, #initialize

Constructor Details

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

Instance Method Details

#button_textObject



250
251
252
# File 'lib/superform/rails.rb', line 250

def button_text
  @attributes.fetch(:value, dom.value).titleize
end

#field_attributesObject



254
255
256
# File 'lib/superform/rails.rb', line 254

def field_attributes
  { id: dom.id, name: dom.name, value: dom.value }
end

#template(&content) ⇒ Object



245
246
247
248
# File 'lib/superform/rails.rb', line 245

def template(&content)
  content ||= Proc.new { button_text }
  button(**attributes, &content)
end