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

List Datetime in forms

Started by Muut Archive 10 years ago · 4 replies · 440 views
10 years ago

Hi everyone.

Currently playing with Grav and pages forms, I'm having a hard time with date and datetime fields.
First of all, I'm not totally sure of what I should expect from the date field. Right now, it just looks like a text field but maybe I'm just using it wrong.
I'm also trying to use datetime fields nested into a list field. Something like the header.buttons in the showcase.yaml form from antimatter. The problem is that once nested, it just looks like any other text field. I suspect it's an expected behaviour but if you got any ideas on how to achieve that, I would be glad.

Thank you,

10 years ago

Hi, post some blueprints examples here (properly formatted by using triple dashes or triple backticks) and tell what you expect / what is happening so I can add them to the theme and check.

10 years ago

For the first question, I used something like this:

YAML
date:
   type: date
   label: Date
   name: date

Actually, I don't really know what to expect as I didn't find any use of the date type in antimatter or in the system blueprints. I think I expected something like a "select a date in a calendar" field but I just got a regular text field where I can write text and without any "valid/unvalid" behaviour.

About the nested list>datetime, my form is similar to this:

YAML
dates:
   label: Dates
   name: dateslist
   type: list
   fields:
      datein:
         type: datetime
         label: Date in
         name: datein
      dateout: 
         type: datetime
         label: Date out
         name:dateout 

I use the list so I can add a undefined amount of datein/dateout couples to a page. It seems to work quite well within the button tab of antimatter>showcase blueprint.
Usually, when I use the datetime field, I have a calendar/time selector but once nested, It becomes a regular text field, leaving me unable to pick a date.

I hope I gave you the informations you need.

10 years ago

date uses the HTML5 date field. Depends on the browser how it's rendered. Chrome:

Screen Shot 2016-02-15 at 13

datetime uses JS rendering:

Screen Shot 2016-02-15 at 13

As for datetime fields in lists, not yet supported due to more JS needed to render them. Hopefully will be supported in the next admin javascript iteration we're doing.

10 years ago

Ok, thanks for the quick answer.
I think I will use date for now. Too bad it's not yet supported by all browsers.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1356 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago