grav icon indicating copy to clipboard operation
grav copied to clipboard

Admin custom datetime doesn't get saved

Open jgp-lukasz opened this issue 5 years ago • 4 comments

When editing custom header with datetime type it gets saved only when it was blank. When there is a value saved in page .md file it doesn't save again date and time selected with timepicker. It works fine when changed in Expert mode in md file or directly in default.md file. Is it because it's default or there is any other problem? My blueprint default.yaml file:

title: Page Content
@extends: 
  type: default
  context: blueprints://pages 
form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        content:
          type: tab
          fields:
            header.taxonomy:
              type: taxonomy
              label: tags
              multiple: true
              validate:
                type: array
            header.date:
              type: datetime
              label: Reserved
              toggleable: true
              help: Please select how long the advert is reserved for.

Steps to reproduce:

  1. Add custom header with datetime in blueprints
  2. Edit and save it in admin / page
  3. Try editing and saving again - doesn't change on save - gets back to old value

jgp-lukasz avatar Mar 29 '19 11:03 jgp-lukasz

I've just come across what I believe is a related datetime issue. If I add this to my page blueprint:

header.releasedate:
  type: datetime
  label: Release Year

I can pick and save datetimes fine. But if I add the format field:

header.releasedate:
  type: datetime
  label: Release Date
  format: "Y"

Then I start getting display glitches - it can save the year to the page.md file but some years display in the admin panel as 1969 while others are ok. If I adjust the format to other options like "jS M Y" I get glitches like "7o Aug 2007". So far the only options that work correctly are to leave the format field out, or to modify it to "M Y".

agentirons avatar Aug 25 '20 17:08 agentirons

You need a year field, I think it may actually exist. Datetime needs at least the full date in order to work.

mahagr avatar Aug 25 '20 17:08 mahagr

Mmm. I’m having this issue as well. I could not find a year field in the list and the fields documentation says datetime supports format.

arkhi avatar Jan 04 '22 19:01 arkhi

It should be easy to create the field yourself.

mahagr avatar Jan 05 '22 08:01 mahagr