Class: CCS::Components::GovUK::Field::Inputs::DateInput::Item
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::Field::Inputs::DateInput::Item
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/field/inputs/date_input/item.rb
Overview
GOV.UK Date Inputs item
This is used to generate an individual date input item
Instance Method Summary collapse
-
#initialize(attribute:, name:, context:, input: {}, label: {}, **options) ⇒ Item
constructor
A new instance of Item.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the date input item.
Constructor Details
#initialize(attribute:, name:, context:, input: {}, label: {}, **options) ⇒ Item
Returns a new instance of Item.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ccs/components/govuk/field/inputs/date_input/item.rb', line 39 def initialize(attribute:, name:, context:, input: {}, label: {}, **) input[:classes] = "govuk-date-input__input #{input[:classes]}".rstrip input[:classes] << ' govuk-input--error' if [:error_message] (input[:attributes] ||= {})[:inputmode] ||= 'numeric' label[:text] ||= name.capitalize label[:classes] = 'govuk-date-input__label' @input = Input::TextInput.new(attribute: "#{attribute}_#{name}", label: label, model: [:model], form: [:form], context: context, **input) end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the date input item
56 57 58 |
# File 'lib/ccs/components/govuk/field/inputs/date_input/item.rb', line 56 def render tag.div(input.render, class: 'govuk-date-input__item') end |