Sha256: 44edaae8158ce51d0fae76e3be8b050e7557d0f7bfe042c44a0d3b8a4ccfef22
Contents?: true
Size: 1.7 KB
Versions: 5
Compression:
Stored size: 1.7 KB
Contents
module GOVUKDesignSystemFormBuilder module Elements class TextArea < Base def initialize(builder, object_name, attribute_name, hint_text:, label:, rows:, max_words:, max_chars:, threshold:, **extra_args, &block) super(builder, object_name, attribute_name, &block) @label = label @hint_text = hint_text @extra_args = extra_args @max_words = max_words @max_chars = max_chars @threshold = threshold @rows = rows end def html Containers::CharacterCount.new(@builder, max_words: @max_words, max_chars: @max_chars, threshold: @threshold).html do Containers::FormGroup.new(@builder, @object_name, @attribute_name).html do @builder.safe_join( [ [label_element, hint_element, error_element, supplemental_content].map(&:html), @builder.text_area( @attribute_name, id: field_id(link_errors: true), class: govuk_textarea_classes, aria: { describedby: described_by( hint_id, error_id, supplemental_id ) }, **@extra_args.merge(rows: @rows) ) ].flatten.compact ) end end end private def govuk_textarea_classes %w(govuk-textarea).tap do |classes| classes.push('govuk-textarea--error') if has_errors? classes.push('govuk-js-character-count') if limit? end end def limit? @max_words || @max_chars end end end end
Version data entries
5 entries across 5 versions & 1 rubygems