%= form_with(model: entry, local: true) do |form| %>
<% if entry.errors.any? %>
<%= pluralize(entry.errors.count, "Fehler") %> verhinderten das Speichern:
<% entry.errors.full_messages.each do |msg| %>
- <%= msg %>
<% end %>
<% end %>
<%= form.label :date, 'Datum', class: 'form-label' %>
<%= form.date_field :date,
class: 'form-control flatpickr',
data: {
enable_time: false,
altInput: true,
altFormat: 'd.m.Y',
dateFormat: 'Y-m-d' # Wichtig: Flatpickr braucht `dateFormat`
},
value: (form.object.date) %>
<%= form.label :hours, 'Stunden', class: 'form-label' %>
<%= form.number_field :hours,
class: 'form-control',
min: 0,
value: form.object.hours || 0 %>
<%= form.label :minutes, 'Minuten', class: 'form-label' %>
<%= form.number_field :minutes,
class: 'form-control',
min: 0, max: 59,
value: form.object.minutes || 0 %>
<%= form.label :praktikums_typ, 'Praktikumstyp', class: 'form-label' %>
<%= form.select :praktikums_typ, Entry::PRAKTIKUMSTYPEN, {}, class: 'form-select' %>
<%= form.label :entry_art, 'Art', class: 'form-label' %>
<%= form.select :entry_art, Entry::ENTRY_ARTEN, {}, class: 'form-select', id: 'entry_art_select' %>
<%= form.label :distance_km, 'Entfernung (km) Gesamt', class: 'form-label' %>
<%= form.number_field :distance_km,
class: 'form-control',
min: 0,
value: form.object.distance_km || 0 %>
<%= form.label :beschreibung, 'Beschreibung', class: 'form-label' %>
<%= form.text_field :beschreibung, class: 'form-control' %>
<%= form.label :kosten, 'Kosten (z. B. Teilnahmegebühr)', class: 'form-label' %>
<%= form.number_field :kosten, class: 'form-control', min: 0, step: 0.01 %>
<%= form.submit 'Speichern', class: 'btn btn-primary' %>
<%= link_to 'Zurück', entries_path, class: 'btn btn-secondary ms-2' %>
<% end %>