<%
  key ||= false
  name ||= false
  from_value ||= ""
  to_value ||= ""
  aria_controls_id ||= false
  date_errors_from ||= nil
  date_errors_to ||= nil
%>
<% if key && name %>
  <%= render "components/expander", {
      title: "Date"
    } do %>
    <div class="app-c-date-filter govuk-!-margin-bottom-0" id="<%= key %>" <% if aria_controls_id %> data-module="enable-aria-controls"<% end %>>
      <%= render "govuk_publishing_components/components/input", {
        label: {
          text: name + " after"
        },
        name: key + "[from]",
        id: key + "[from]",
        value: from_value,
        controls: aria_controls_id,
        hint: "For example, 2005 or 21/11/2014",
        error_message: date_errors_from
      } %>
  
      <%= render "govuk_publishing_components/components/input", {
        label: {
          text: name + " before"
        },
        name: key + "[to]",
        id: key + "[to]",
        value: to_value,
        controls: aria_controls_id,
        hint: "For example, 2005 or 21/11/2014",
        error_message: date_errors_to
      } %>
    </div>
  <% end %>
<% end %>

<%
  key ||= false
  name ||= false
  from_value ||= ""
  to_value ||= ""
  aria_controls_id ||= false
  date_errors_from ||= nil
  date_errors_to ||= nil
%>
<% if key && name %>
  <%= render "components/expander", { title: name } do %>
    <div class="app-c-date-filter govuk-!-margin-bottom-0" id="<%= key %>" <% if aria_controls_id %> data-module="enable-aria-controls"<% end %>>
      <%= render "govuk_publishing_components/components/input", {
        label: {
          text: name + " after"
        },
        name: key + "[from]",
        id: key + "[from]",
        value: from_value,
        controls: aria_controls_id,
        hint: "For example, 2005 or 21/11/2014",
        error_message: date_errors_from
      } %>

      <%= render "govuk_publishing_components/components/input", {
        label: {
          text: name + " before"
        },
        name: key + "[to]",
        id: key + "[to]",
        value: to_value,
        controls: aria_controls_id,
        hint: "For example, 2005 or 21/11/2014",
        error_message: date_errors_to
      } %>
    </div>
  <% end %>
<% end %>

Use name for date filter title
Use name for date filter title

At the moment the title of the date filter is hard coded to the string
"Date". This means that if we want to display two date filters, then we
end up with two filters both with the word "Date".

I'm not really clear on the consequence for this and whether it was
intentional, so it might need some product/frontend approval first.
