Class: GOVUKDesignSystemFormBuilder::Elements::Submit

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

Instance Method Summary collapse

Methods included from Traits::HTMLAttributes

#attributes

Methods inherited from Base

#field_id, #to_s

Constructor Details

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

Returns a new instance of Submit.


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

def initialize(builder, text, warning:, secondary:, classes:, 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
  @classes              = classes
  @validate             = validate
  @disabled             = disabled
  @html_attributes      = kwargs
  @block_content        = capture { block.call } if block_given?
end

Instance Method Details

#htmlObject


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

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