The stock Grav `datetime` field template is deprecated and falls back to a plain text box, so `type: datetime` + `default: now` rendered a raw input showing the literal word "now" — unusable. Add a theme override at templates/forms/fields/datetime/datetime.html.twig that renders a native <input type="datetime-local"> (real calendar+clock, great on mobile), drop the `default: now`, and prefill the current local time from post-form.js. Also add `date` to the existing client-side validator. Together with the picker (which can't hold an invalid value) this stops a bad/empty date from round-tripping to the server — which was the trigger that made Grav re-render the managed FilePond field from the session flash as filename-only inputs and resurrect a photo the user had removed. Grav still reformats the submitted value to the blueprint `format: 'Y-m-d H:i'` on save, so stored dates and folder slugs are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
179 lines
4.9 KiB
Markdown
179 lines
4.9 KiB
Markdown
---
|
|
title: 'New Entry'
|
|
template: post-form
|
|
access:
|
|
site.login: true
|
|
|
|
# Parent (write target) is injected server-side from site.active_trip by the
|
|
# cache-on-save plugin (onFormValidationProcessed) — no manual sync needed.
|
|
pageconfig:
|
|
slug_field: 'date,title'
|
|
overwrite_mode: false
|
|
|
|
pagefrontmatter:
|
|
template: entry
|
|
published: true
|
|
|
|
form:
|
|
name: new-entry
|
|
action: /post
|
|
enctype: multipart/form-data
|
|
fields:
|
|
# Photos come first — they anchor what you'll write (Photos → Title →
|
|
# Content). After upload post-form.js auto-collapses this into a summary
|
|
# bar so the thumbnails don't crowd the writing area.
|
|
-
|
|
name: photos
|
|
label: Photos (max 4)
|
|
# Grav-managed filepond field. post-form.js hooks its beforeAddFile
|
|
# to convert HEIC->JPEG in the browser, then re-adds the JPEG via the
|
|
# public pond.addFile() API — FilePond keeps ownership of the upload
|
|
# and page-attach contract (U4).
|
|
type: filepond
|
|
multiple: true
|
|
destination: '@self'
|
|
limit: 4
|
|
accept:
|
|
- 'image/*'
|
|
|
|
-
|
|
name: title
|
|
label: Title
|
|
type: text
|
|
validate:
|
|
required: true
|
|
|
|
-
|
|
name: date
|
|
label: Date & Time
|
|
# Rendered as a native <input type="datetime-local"> by the theme
|
|
# override at templates/forms/fields/datetime/datetime.html.twig.
|
|
# No `default: now` — the stock text fallback would print the literal
|
|
# string "now" into the picker; post-form.js prefills the current
|
|
# local time instead (and the client validator requires this field).
|
|
type: datetime
|
|
format: 'Y-m-d H:i'
|
|
validate:
|
|
required: true
|
|
|
|
-
|
|
name: content
|
|
label: "What happened today?"
|
|
type: textarea
|
|
rows: 10
|
|
validate:
|
|
required: true
|
|
|
|
-
|
|
name: lat
|
|
label: Latitude
|
|
type: text
|
|
placeholder: 'tap "Get Location" below'
|
|
|
|
-
|
|
name: lng
|
|
label: Longitude
|
|
type: text
|
|
placeholder: ''
|
|
|
|
-
|
|
name: location_city
|
|
label: City
|
|
type: text
|
|
placeholder: 'e.g. Kyoto'
|
|
|
|
-
|
|
name: location_country
|
|
label: Country
|
|
type: text
|
|
placeholder: 'e.g. Japan'
|
|
|
|
-
|
|
name: weather_desc
|
|
label: Weather Condition
|
|
type: select
|
|
default: ''
|
|
options:
|
|
'': '— none —'
|
|
'Sunny': '☀️ Sunny'
|
|
'Partly cloudy': '⛅ Partly cloudy'
|
|
'Cloudy': '☁️ Cloudy'
|
|
'Foggy': '🌫️ Foggy'
|
|
'Drizzle': '🌦️ Drizzle'
|
|
'Rain': '🌧️ Rain'
|
|
'Snow': '❄️ Snow'
|
|
'Thunderstorm': '⛈️ Thunderstorm'
|
|
|
|
-
|
|
name: weather_temp_c
|
|
label: 'Temperature (°C)'
|
|
type: number
|
|
placeholder: 'tap "Get Weather" or type it'
|
|
validate:
|
|
min: -60
|
|
max: 60
|
|
|
|
-
|
|
name: transport_mode
|
|
label: 'How I got here'
|
|
type: select
|
|
default: ''
|
|
options:
|
|
'': '— not specified —'
|
|
'walking': '🚶 Walking'
|
|
'bicycle': '🚲 Bicycle'
|
|
'bus': '🚌 Bus'
|
|
'train': '🚆 Train'
|
|
'car': '🚗 Car'
|
|
'plane': '✈️ Plane'
|
|
|
|
# Advanced fields — collapsed behind "More options" (see U5)
|
|
-
|
|
name: hero_image
|
|
label: Hero Image Filename
|
|
type: text
|
|
classes: advanced-field
|
|
placeholder: 'photo.jpg'
|
|
help: 'Filename of the hero/header image. Leave blank to use the first uploaded photo.'
|
|
|
|
-
|
|
name: force_connect
|
|
label: Force connector line
|
|
type: toggle
|
|
classes: advanced-field
|
|
highlight: 0
|
|
default: 0
|
|
options:
|
|
1: 'Yes'
|
|
0: 'No'
|
|
validate:
|
|
type: bool
|
|
|
|
-
|
|
name: featured
|
|
label: Featured highlight
|
|
type: toggle
|
|
classes: advanced-field
|
|
highlight: 0
|
|
default: 0
|
|
options:
|
|
1: 'Yes'
|
|
0: 'No'
|
|
validate:
|
|
type: bool
|
|
|
|
novalidate: true
|
|
|
|
buttons:
|
|
-
|
|
type: submit
|
|
value: Post Daily
|
|
classes: btn-post
|
|
|
|
process:
|
|
add_page: true
|
|
upload: true
|
|
message: 'Entry posted successfully!'
|
|
reset: true
|
|
---
|