Class: CCS::Components::GovUK::Field::Inputs
- Inherits:
-
CCS::Components::GovUK::Field
- Object
- Base
- CCS::Components::GovUK::Field
- CCS::Components::GovUK::Field::Inputs
- Defined in:
- lib/ccs/components/govuk/field/inputs.rb,
lib/ccs/components/govuk/field/inputs/item.rb,
lib/ccs/components/govuk/field/inputs/radios.rb,
lib/ccs/components/govuk/field/inputs/checkboxes.rb,
lib/ccs/components/govuk/field/inputs/date_input.rb,
lib/ccs/components/govuk/field/inputs/item/radio.rb,
lib/ccs/components/govuk/field/inputs/item/divider.rb,
lib/ccs/components/govuk/field/inputs/item/checkbox.rb,
lib/ccs/components/govuk/field/inputs/item/radio/tag.rb,
lib/ccs/components/govuk/field/inputs/date_input/item.rb,
lib/ccs/components/govuk/field/inputs/item/radio/form.rb,
lib/ccs/components/govuk/field/inputs/item/checkbox/tag.rb,
lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
Overview
GOV.UK Field Inputs
This class is used to create a form for a list of fields, e.g. radios or checkboxes. It will wrap the inputs in the form group and then the fieldset and:
-
display the hint (if there is one)
-
find and display the error message (if there is one)
Direct Known Subclasses
Defined Under Namespace
Classes: Checkboxes, DateInput, Item, Radios
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(attribute:, fieldset: nil, **options) ⇒ Inputs
constructor
A new instance of Inputs.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML to wrap arround a GDS form component.
Constructor Details
#initialize(attribute:, fieldset: nil, **options) ⇒ Inputs
Returns a new instance of Inputs.
32 33 34 35 36 37 38 39 40 |
# File 'lib/ccs/components/govuk/field/inputs.rb', line 32 def initialize(attribute:, fieldset: nil, **) super(attribute: attribute, **) return unless fieldset set_described_by(fieldset, @attribute, @error_message, [:hint]) @fieldset = Fieldset.new(context: @context, **fieldset) end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML to wrap arround a GDS form component
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ccs/components/govuk/field/inputs.rb', line 48 def render(&block) super() do || if fieldset fieldset.render do field_inner_html(, &block) end else field_inner_html(, &block) end end end |