ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.7k stars 384 forks source link

Creating a datetime field in Ponzu #244

Closed joesb closed 5 years ago

joesb commented 6 years ago

I'm wondering how to create a content field for a datetime e.g. opening/closing dates of an event. Ideally it would be formatted into year, month, day (etc.) fields in the UI – taking some inspiration from the content publishTime UI, maybe. Granularity of field elements might be adaptable in some way.

Any resources or pointers on how to do it? (I'm new to Go and Ponzu, and hoping to learn some Go by working with Ponzu.)

Many thanks, in anticipation.

nilslice commented 6 years ago

@joesb - You can add any arbitrary HTML attributes to the inputs exported from the editor package. Could you try adding the type attr set to date in the input function?

for example:

        editor.Field{
            View: editor.Input("StartDate", p, map[string]string{
                "label":       "StartDate",
                "type":        "date",
                "placeholder": "Enter the Author here",
            }),
        },
joesb commented 6 years ago

Thanks for this. I'll have a got and see how far I get.

nilslice commented 6 years ago

@joesb - any luck? going to close out this issue unless you're having problems with it :)

joesb commented 6 years ago

Sorry @nilslice - I've not had a chance to get onto it again since asking. Gah!

Do please feel happy closing this issue and I can always ask more questions at a later date. Thanks a gazillion for your help.

nilslice commented 6 years ago

No worries -- I'll leave it open, not a problem at all. Happy to help!

joshdstockdale commented 6 years ago

@nilslice Your solution worked perfectly for me.

olliephillips commented 5 years ago

Closing this issue. It appears to be answered/resolved. Please reopen if not the case.