Class: CCS::Components::GovUK::Field::Inputs::Item
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/field/inputs/item.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/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 Item
This class is used to provided the shared HTML for a checkbox item or radio item. It wraps these items with the following:
-
Item label
-
Item hint
-
Item conditional content
Defined Under Namespace
Classes: Checkbox, Divider, Radio
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(attribute:, value:, item_class:, hint: nil, conditional: nil, **options) ⇒ Item
constructor
A new instance of Item.
-
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML to wrap arround a input.
Constructor Details
#initialize(attribute:, value:, item_class:, hint: nil, conditional: nil, **options) ⇒ Item
Returns a new instance of Item.
59 60 61 62 63 64 65 66 67 |
# File 'lib/ccs/components/govuk/field/inputs/item.rb', line 59 def initialize(attribute:, value:, item_class:, hint: nil, conditional: nil, **) super(**) initialise_item_hint(attribute, value, hint) if hint initialize_item_conditional(attribute, value, conditional) if conditional && conditional[:content] @attribute = attribute @value = value @item_class = item_class end |
Instance Method Details
#render { ... } ⇒ ActiveSupport::SafeBuffer
Generates the HTML to wrap arround a input
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ccs/components/govuk/field/inputs/item.rb', line 77 def render capture do concat(tag.div(class: @item_class) do concat(yield) concat(label.render) concat(hint.render) if hint end) concat(conditional_content) if conditional_content end end |