Sha256: eef3e370c3e7a0aacf45459714d1283232e69faf6937add50fcbcc3439f3560b
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true require_relative '../../components/govuk/form_group' module CCS module FrontendHelpers::GovUKFrontend # = GOV.UK FormGroup # # This helper is used for generating the form group component from the Government Design Systems module FormGroup # Generates the HTML for the GOV.UK Warning text component # # @param (see CCS::Components::GovUK::FormGroup#initialize) # # @option options [String] :classes additional CSS classes for the form group HTML # @option options [ActiveModel] :model (nil) model that will be used to find an error message # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML # # @yield (see CCS::Components::GovUK::FormGroup#render) # # @yieldparam (see CCS::Components::GovUK::FormGroup#render) # # @return (see CCS::Components::GovUK::FormGroup#render) def govuk_form_group(attribute, **options, &block) error_message = if options[:model] model.errors[attribute].first else options[:error_message] end Components::GovUK::FormGroup.new(context: self, attribute: attribute, error_message: error_message, **options).render(&block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ccs-frontend_helpers-0.1.0.rc.2 | lib/ccs/frontend_helpers/govuk_frontend/form_group.rb |