Sha256: d4e02d5019a555027be779eec544c2a17231efb24a0a2251b8d91326363d1921
Contents?: true
Size: 1.88 KB
Versions: 5
Compression:
Stored size: 1.88 KB
Contents
module GOVUKDesignSystemFormBuilder module Elements module Radios class Collection < GOVUKDesignSystemFormBuilder::Base def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint_text:, legend:, inline:, small:, bold_labels:, &block) super(builder, object_name, attribute_name, &block) @collection = collection @value_method = value_method @text_method = text_method @hint_method = hint_method @inline = inline @small = small @legend = legend @hint_text = hint_text @bold_labels = hint_method.present? || bold_labels end def html Containers::FormGroup.new(@builder, @object_name, @attribute_name).html do Containers::Fieldset.new(@builder, legend: @legend, described_by: [error_id, hint_id, supplemental_id]).html do @builder.safe_join( [ hint_element.html, error_element.html, supplemental_content.html, Containers::Radios.new(@builder, inline: @inline, small: @small).html do @builder.safe_join(build_collection) end ] ) end end end private def build_collection @collection.map.with_index do |item, i| Elements::Radios::CollectionRadioButton.new( @builder, @object_name, @attribute_name, item, value_method: @value_method, text_method: @text_method, hint_method: @hint_method, link_errors: has_errors? && i.zero?, bold_labels: @bold_labels ).html end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems