18F/identity-dashboard

View on GitHub
app/views/banners/_form.html.erb

Summary

Maintainability
Test Coverage
<%= simple_form_for(banner) do |form| %>
  <% if banner.errors.any? %>
    <div style="color: red">
      <h2><%= pluralize(banner.errors.count, "error") %> prohibited this banner from being saved:</h2>

      <ul>
        <% banner.errors.each do |error| %>
          <li><%= error.full_message %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <fieldset class='usa-fieldset'>
    <%= 
      form.input :message, 
        input_html: { class: 'usa-input' },
        label_html: { class: 'usa-input-required'},
        label: 'Message',
        hint: t('banner_form.message_hint')
    %>

    <%# Since this is an admin-only UI, opting for html5 date inputs instead of the design system's date inputs %>

    <%=
      form.input :start_date, 
        as: :date,
        html5: true,
        label_html: { class: 'usa-label' },
        input_html: { class: 'usa-select' }

    %>
    <%=
      form.input :end_date, 
        as: :date,
        html5: true,
        label_html: { class: 'usa-label' },
        input_html: { class: 'usa-select' }
    %>

    </fieldset>
  <br>
  <%= form.button :submit, 'Save', :class => "usa-button" %>
<% end %>