Class: CCS::Components::GovUK::Field::Inputs::Item::Radio::Form

Inherits:
CCS::Components::GovUK::Field::Inputs::Item::Radio show all
Defined in:
lib/ccs/components/govuk/field/inputs/item/radio/form.rb

Overview

GOV.UK Field Inputs Radio form tag

This is used to generate an individual radio item using form.check_box

Constant Summary

Constants inherited from CCS::Components::GovUK::Field::Inputs::Item::Radio

DEFAULT_ATTRIBUTES, ITEM_TYPE

Constants inherited from Base

Base::DEFAULT_ATTRIBUTES

Instance Method Summary collapse

Constructor Details

#initialize(attribute:, label:, **options) ⇒ Form

Returns a new instance of Form.



19
20
21
22
23
24
25
26
# File 'lib/ccs/components/govuk/field/inputs/item/radio/form.rb', line 19

def initialize(attribute:, label:, **options)
  super

  (label[:attributes] ||= {})[:value] = @value
  label[:attributes][:for] = @options[:attributes][:id] if @options[:attributes][:id]

  @label = Label.new(attribute: attribute, form: @options[:form], context: @context, **label)
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the radio input

Returns:

  • (ActiveSupport::SafeBuffer)


32
33
34
35
36
# File 'lib/ccs/components/govuk/field/inputs/item/radio/form.rb', line 32

def render
  super do
    @options[:form].radio_button(@attribute, @value, **@options[:attributes])
  end
end