Sha256: 38355d127ade6bf85296d0f3aaf60fa737e15307c2301341b5112a70357617d1
Contents?: true
Size: 1.84 KB
Versions: 6
Compression:
Stored size: 1.84 KB
Contents
# frozen_string_literal: true require "govuk_design_system_formbuilder" module Katalyst module GOVUK module Formbuilder module Elements class Combobox < GOVUKDesignSystemFormBuilder::Base include GOVUKDesignSystemFormBuilder::Traits::Error include GOVUKDesignSystemFormBuilder::Traits::Label include GOVUKDesignSystemFormBuilder::Traits::Hint include GOVUKDesignSystemFormBuilder::Traits::HTMLAttributes def initialize(builder, object_name, attribute_name, options_or_src, options:, form_group:, label:, hint:, caption:, **kwargs, &block) super(builder, object_name, attribute_name) @block = block @form_group = form_group @hint = hint @label = label @caption = caption @options_or_src = options_or_src @options = options @html_attributes = kwargs end def html GOVUKDesignSystemFormBuilder::Containers::FormGroup.new(*bound, **@form_group).html do safe_join([label_element, hint_element, error_element, combobox]) end end private def combobox @builder.combobox(@attribute_name, @options_or_src, **@options, **attributes(@html_attributes), &@block) end def options { id: field_id(link_errors: true), class: classes, aria: { describedby: combine_references(hint_id, error_id) }, } end def classes combine_references(%(#{brand}-combobox), error_class) end def error_class %(#{brand}-combobox--error) if has_errors? end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems