Class: CCS::Components::GovUK::Field::Inputs::Item::Checkbox::Form
- Inherits:
-
CCS::Components::GovUK::Field::Inputs::Item::Checkbox
- Object
- Base
- CCS::Components::GovUK::Field::Inputs::Item
- CCS::Components::GovUK::Field::Inputs::Item::Checkbox
- CCS::Components::GovUK::Field::Inputs::Item::Checkbox::Form
- Defined in:
- lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb
Overview
GOV.UK Field Inputs Checkbox form tag
This is used to generate an individual checkbox item using form.check_box
Constant Summary
Constants inherited from CCS::Components::GovUK::Field::Inputs::Item::Checkbox
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(attribute:, label:, **options) ⇒ Form
constructor
A new instance of Form.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the checkbox input.
Constructor Details
#initialize(attribute:, label:, **options) ⇒ Form
Returns a new instance of Form.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb', line 19 def initialize(attribute:, label:, **) super (label[:attributes] ||= {})[:value] = @value label[:attributes][:for] = [:attributes][:id] if [:attributes][:id] [:attributes][:multiple] = true [:attributes][:include_hidden] = false @label = Label.new(attribute: attribute, form: [:form], context: @context, **label) end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the checkbox input
35 36 37 38 39 |
# File 'lib/ccs/components/govuk/field/inputs/item/checkbox/form.rb', line 35 def render super do [:form].check_box(@attribute, [:attributes], @value) end end |