Sha256: cd5116c45f51db2f9726e9ff7679264047192ef28e122881b92028879d41fd17

Contents?: true

Size: 1.67 KB

Versions: 50

Compression:

Stored size: 1.67 KB

Contents

<%
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)

  options ||= []
  id ||= false
  label ||= false
  full_width ||= false
  name ||= id
  is_page_heading ||= false
  heading_size = false unless shared_helper.valid_heading_size?(heading_size)
  error_message ||= nil
  error_id ||= nil

  if error_message || error_id
    error_id = "error-#{SecureRandom.hex(4)}" unless error_id
    aria_describedby = { describedby: error_id }
  end

  css_classes = %w(govuk-form-group gem-c-select)
  css_classes << "govuk-form-group--error" if error_message

  select_classes = %w(govuk-select)
  select_classes << "gem-c-select__select--full-width" if full_width
  select_classes << "govuk-select--error" if error_id

  label_classes = %w(govuk-label)
  label_classes << "govuk-label--#{heading_size}" if heading_size

  select_helper = GovukPublishingComponents::Presenters::SelectHelper.new(options)
  data_module = { module: "track-select-change" } unless select_helper.data_tracking?.eql?(false)
%>
<% if options.any? && id && label %>
  <%= content_tag :div, class: css_classes do %>
    <% if is_page_heading %>
      <%= tag.h1 label_tag(id, label, class: label_classes), class: "gem-c-title__text" %>
    <% else %>
      <%= label_tag(id, label, class: label_classes) %>
    <% end %>

    <% if error_message %>
      <%= render "govuk_publishing_components/components/error_message", {
        id: error_id,
        text: error_message
      } %>
    <% end %>

    <%= select_tag name, options_for_select(select_helper.option_markup, select_helper.selected_option), id: id, class: select_classes, data: data_module, aria: aria_describedby %>
  <% end %>
<% end %>

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
govuk_publishing_components-28.4.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-28.3.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-28.2.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-28.1.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-28.0.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.20.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.19.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.18.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.17.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.16.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.15.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.14.2 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.14.1 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.14.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.13.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.12.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.11.0 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.10.5 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.10.4 app/views/govuk_publishing_components/components/_select.html.erb
govuk_publishing_components-27.10.3 app/views/govuk_publishing_components/components/_select.html.erb