Class: Superform::Rails::Components::Button

Inherits:
Field
  • Object
show all
Defined in:
lib/superform/rails/components/button.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

#button_textObject



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

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

#field_attributesObject



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

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

#view_template(&content) ⇒ Object



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

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