Class: FoxTail::ButtonBaseComponent

Inherits:
ClickableComponent show all
Includes:
Concerns::Formable
Defined in:
app/components/fox_tail/button_base_component.rb

Direct Known Subclasses

ButtonComponent, IconButtonComponent

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from ClickableComponent

#call, #link?, #root_tag_name, stimulus_controller_name, #stimulus_controller_options, #use_stimulus?

Methods inherited from BaseComponent

classname_merger, #initialize, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

This class inherits a constructor from FoxTail::BaseComponent

Instance Method Details

#before_renderObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/components/fox_tail/button_base_component.rb', line 35

def before_render
  super

  if value.is_a?(Symbol) && object_name? && method_name?
    html_attributes[:name] = field_name value
    html_attributes[:id] = field_id value
  end

  html_attributes[:value] = value if value?

  if form_method? && !/post|get/i.match?(form_method) && !html_attributes.key?(:name) && !html_attributes.key?(:value)
    html_attributes[:formmethod] = :post
    html_attributes[:name] = "_method"
    html_attributes[:value] = form_method
  end
end