Module: StimulusPlumbers::Form::Fields::Inputs::Submit

Included in:
Builder
Defined in:
lib/stimulus_plumbers/form/fields/inputs/submit.rb

Instance Method Summary collapse

Instance Method Details

#submit(value = nil, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stimulus_plumbers/form/fields/inputs/submit.rb', line 8

def submit(value = nil, options = {})
  if value.is_a?(Hash)
    options = value
    value = nil
  end
  value ||= submit_default_value
  type     = options.delete(:type)    { :default }
  variant  = options.delete(:variant) { :primary }

  Components::Button.new(@template).build(type: type, variant: variant) do |attrs|
    @template.tag.button(
      type: "submit",
      **merge_html_options(attrs, options)
    ) { value }
  end
end