Sha256: 25046b37b085f419a19270dcb13fe8a94f0d8af6ff5855ac8b1980c13d16e7ab
Contents?: true
Size: 1.84 KB
Versions: 6
Compression:
Stored size: 1.84 KB
Contents
<% id ||= "input-#{SecureRandom.hex(4)}" value ||= nil type ||= "text" describedby ||= false data ||= nil label ||= nil hint ||= nil error_message ||= nil error_items ||= nil autofocus ||= nil tabindex ||= nil readonly ||= nil has_error = error_message || error_items&.any? hint_id = "hint-#{SecureRandom.hex(4)}" error_id = "error-#{SecureRandom.hex(4)}" css_classes = %w(gem-c-input govuk-input) css_classes << "govuk-input--error" if has_error form_group_css_classes = %w(govuk-form-group) form_group_css_classes << "govuk-form-group--error" if has_error aria_described_by ||= nil if hint || has_error || describedby aria_described_by = [] aria_described_by << hint_id if hint aria_described_by << error_id if has_error aria_described_by << describedby if describedby aria_described_by = aria_described_by.join(" ") end %> <%= content_tag :div, class: form_group_css_classes do %> <% if label %> <%= render "govuk_publishing_components/components/label", { html_for: id }.merge(label.symbolize_keys) %> <% end %> <% if hint %> <%= render "govuk_publishing_components/components/hint", { id: hint_id, text: hint } %> <% end %> <% if error_message %> <%= render "govuk_publishing_components/components/error_message", { id: error_id, text: error_message } %> <% elsif error_items %> <%= render "govuk_publishing_components/components/error_message", { id: error_id, text: raw(error_items.map { |item| item[:text] }.join("<br/>")) } %> <% end %> <%= tag.input name: name, value: value, class: css_classes, id: id, type: type, data: data, tabindex: tabindex, autofocus: autofocus, readonly: readonly, aria: { describedby: aria_described_by } %> <% end %>
Version data entries
6 entries across 6 versions & 1 rubygems