Class: GOVUKDesignSystemFormBuilder::Elements::Submit

Inherits:
Base
  • Object
show all
Includes:
Traits::HTMLAttributes, Traits::HTMLClasses
Defined in:
lib/govuk_design_system_formbuilder/elements/submit.rb

Instance Method Summary collapse

Methods included from Traits::HTMLAttributes

#attributes

Methods included from Traits::HTMLClasses

#build_classes

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block) ⇒ Submit

Returns a new instance of Submit.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/govuk_design_system_formbuilder/elements/submit.rb', line 8

def initialize(builder, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block)
  super(builder, nil, nil)

  fail ArgumentError, 'buttons can be warning or secondary' if warning && secondary

  @text                 = build_text(text)
  @prevent_double_click = prevent_double_click
  @warning              = warning
  @secondary            = secondary
  @inverse              = inverse
  @validate             = validate
  @disabled             = disabled
  @html_attributes      = kwargs
  @block_content        = capture { block.call } if block_given?
end

Instance Method Details

#htmlObject



24
25
26
# File 'lib/govuk_design_system_formbuilder/elements/submit.rb', line 24

def html
  @block_content.present? ? button_group : submit
end