<% described_by = local_assigns[:describedBy] %> <% form_group_classes = class_names( "govuk-form-group", { "govuk-form-group--error" => local_assigns[:errorMessage] }, local_assigns.dig(:formGroup, :classes) ) %>
<%= render("components/govuk_label", html: local_assigns.dig(:label, :html), text: local_assigns.dig(:label, :text), classes: local_assigns.dig(:label, :classes), isPageHeading: local_assigns.dig(:label, :isPageHeading), attributes: local_assigns.dig(:label, :attributes), for: local_assigns[:id]) %> <% if local_assigns[:hint] %> <% hint_id = "#{local_assigns[:id]}-hint" %> <% described_by = described_by ? "#{described_by} #{hint_id}" : hint_id %> <%= render("components/govuk_hint", id: hint_id, classes: local_assigns.dig(:hint, :classes), attributes: local_assigns.dig(:hint, :attributes), html: local_assigns.dig(:hint, :html), text: local_assigns.dig(:hint, :text)) %> <% end %> <% if local_assigns[:errorMessage] %> <% error_id = "#{local_assigns[:id]}-error" %> <% described_by = described_by ? "#{described_by} #{error_id}" : error_id %> <%= render("components/govuk_error_message", id: error_id, classes: local_assigns.dig(:errorMessage, :classes), attributes: local_assigns.dig(:errorMessage, :attributes), html: local_assigns.dig(:errorMessage, :html), text: local_assigns.dig(:errorMessage, :text), visuallyHiddenText: local_assigns.dig(:errorMessage, :visuallyHiddenText)) %> <% end %> <% if local_assigns[:prefix] || local_assigns[:suffix] %>
<% end %> <% if local_assigns.dig(:prefix, :text) || local_assigns.dig(:prefix, :html) %> <% prefix_attributes = { class: class_names( "govuk-input__prefix", local_assigns.dig(:prefix, :classes) ), 'aria-hidden': true } prefix_attributes.merge!(local_assigns.dig(:prefix, :attributes)) if local_assigns.dig(:prefix, :attributes) prefix_content = local_assigns.dig(:prefix, :html) || local_assigns.dig(:prefix, :text) %> <%= tag.div prefix_content, **prefix_attributes %> <% end %> <% input_attributes = { class: class_names( "govuk-input", local_assigns[:classes], { "govuk-input--error" => local_assigns[:errorMessage] } ), id: local_assigns[:id], name: local_assigns[:name], type: local_assigns[:type] || "text" } input_attributes[:spellcheck] = local_assigns[:spellcheck] unless local_assigns[:spellcheck].nil? input_attributes[:value] = local_assigns[:value] if local_assigns[:value] input_attributes[:'aria-describedby'] = described_by if described_by.present? input_attributes[:autocomplete] = local_assigns[:autocomplete] if local_assigns[:autocomplete] input_attributes[:pattern] = local_assigns[:pattern] if local_assigns[:pattern] input_attributes[:inputmode] = local_assigns[:inputmode] if local_assigns[:inputmode] input_attributes.merge!(local_assigns[:attributes]) if local_assigns[:attributes] %> <%= tag.input(**input_attributes) %> <% if local_assigns.dig(:suffix, :text) || local_assigns.dig(:suffix, :html) %> <% suffix_attributes = { class: class_names( "govuk-input__suffix", local_assigns.dig(:suffix, :classes) ), 'aria-hidden': true } suffix_attributes.merge!(local_assigns.dig(:suffix, :attributes)) if local_assigns.dig(:suffix, :attributes) suffix_content = local_assigns.dig(:suffix, :html) || local_assigns.dig(:suffix, :text) %> <%= tag.div suffix_content, **suffix_attributes %> <% end %> <% if local_assigns[:prefix] || local_assigns[:suffix] %>
<% end %>