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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

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

Solved by Anna View solution

Started by Anna 2 years ago · 2 replies · 212 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 Rene, 1 week ago
2 49 1 week ago
Plugins · by Xavier, 4 weeks ago
2 57 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1184 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 50 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 75 2 months ago