Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

Date format in flex-objects doesn't seem to work?

Solved by Anna View solution

Started by Anna 2 years ago · 2 replies · 430 views
2 years ago

Hey there,

I am creating a calendar thingy which is expected to contain some 200 elements at any given time (events for the next six months). To make the handling easier I wanted to do this with flex-objects and not a custom page template, because in pages the list of sibling events in the Advanced tab would be extremely long.

However – I of course want to be able to sort these entries by date, and that would require me to have one associated field with the date as a "YYYY-MM-DD" string, since flex-objects don't sort properly by date at least in Admin (the way I understand it).

So what I've done is, in termine.yaml (flex-objects definition file):

YAML
    # List view
    list:
      title: name
      order:
        by: datum
        dir: asc
      fields:
        published:
          field:
            type: toggle
            label: Publ
          width: 8
        titel:
          link: edit
        datum:
          format: 'Y-m-d'

This seems to do nothing. The format stays "m/d/Y" and the list doesn't get sorted by that either. What am I doing wrong?

2 years ago

I'm still puzzled by this. In the JSON file the date format actually IS "Y-m-d". Why does Grav Admin show it differently?

If I click the header to sort, the entries do get sorted, but as strings by the format "m/d/Y" which will be problematic during the winter months…

Any ideas are much appreciated!

2 years ago Solution

Found the answer, I was doing it wrong! This works (again in the flex blueprint):

YAML
config:
    data:
        ordering:
            datum: ASC

RTFM… properly 😅

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Vladimir Novak, 2 weeks ago
3 291 2 weeks ago
Plugins · by Mathieu Lecouturier, 3 weeks ago
3 277 3 weeks ago
Plugins · by Slebeig, 2 months ago
1 403 2 months ago
Plugins · by Rene, 2 months ago
2 574 2 months ago
Plugins · by Xavier, 3 months ago
2 490 3 months ago