Sha256: afbda4fdb6802425a447d27152eee8fa819193777e02566f037347139544a2a4
Contents?: true
Size: 1023 Bytes
Versions: 2
Compression:
Stored size: 1023 Bytes
Contents
module GOVUKDesignSystemFormBuilder module Elements class Hint < Base include Traits::Hint def initialize(builder, object_name, attribute_name, text, value = nil, radio: false, checkbox: false) super(builder, object_name, attribute_name) @value = value @hint_text = hint_text(text) @radio_class = radio_class(radio) @checkbox_class = checkbox_class(checkbox) end def html return nil if @hint_text.blank? tag.span(@hint_text, class: hint_classes, id: hint_id) end private def hint_text(supplied) [ supplied.presence, localised_text(:hint) ].compact.first end def hint_classes %w(govuk-hint).push(@radio_class, @checkbox_class).compact end def radio_class(radio) radio ? 'govuk-radios__hint' : nil end def checkbox_class(checkbox) checkbox ? 'govuk-checkboxes__hint' : nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems