UNC-Libraries/hy-c

View on GitHub
app/views/records/edit_fields/_date_created.html.erb

Summary

Maintainability
Test Coverage
<% date_value = params[:action] == 'new' ? Date.today.strftime("%Y-%m-%d") : f.object.date_created %>
<%# Adding "date-input" class sets field to a date field. See /app/inputs/multi_value_input.rb %>
<% use_date_field_class = 'date-input' %>
<% place_holder = 'Date Format YYYY-MM-DD' %>

<% if f.object.multiple? key %>
  <%= f.input :date_created, as: :multi_value, placeholder: place_holder,
              input_html: { class: use_date_field_class} %>
<% else %>
  <%= f.input :date_created, as: :date, html5: true, placeholder: place_holder,
              input_html: { class: use_date_field_class, value: date_value } %>
<% end %>