backdrop-issues
backdrop-issues copied to clipboard
[UX] Add a token-browser-like PHP date format helper dialog
This is a spin-off from #4536.
@BWPanda
There's a bit of scrolling needed to find the actual table of formats, and no way to link straight to it from what I can see. Since I doubt those formats would change much, I wonder if it'd be better for us to create our own page to link to...? Either in Backdrop itself (in a modal like the tokens one), or on b.org/api.b.org.
@jlfranklin
The Date/Time Format Help module will include the documentation directly on the "Add date format" page.
This sounds like a great idea.
Related: https://github.com/backdrop/backdrop-issues/issues/1284
Here's a PR that adds a fieldset of common date/time codes: https://github.com/backdrop/backdrop/pull/4007

It was inspired by the Date/Time Format Help contrib module, though not a direct integration (I figured we don't need to show all codes on this page, just the common ones, then link to PHP's manual for the rest).
Cool, love it!
Some suggestions:
- It could also be a details element, as this help item is new
- It might make sense to collapse it initially
- If the locale/language modules are enabled, one can "localize" these formats, but on that page the help isn't provided (/admin/config/regional/date-time/formats/long/localize)
That's all optional.
Thanks for the suggestions.
- What's the difference/benefit of 'details' over 'fieldset'?
- I was about to say that I considered collapsing by default, but didn't see any benefits in doing so (considering there's nothing below to scroll to), but then I checked and the submit button is down there! So yes, we can either collapse by default, or (preferably) move the fieldset below the submit button...
- Indeed, we should add there too.
I'll work on updating the PR, but not now. It's ~g:ia~ 10:46pm, so I'm off to bed 😉
What's the difference/benefit of 'details' over 'fieldset'?
The details element is supported natively in browsers, IIRC. We used it for a similar use case of "additional information", for the "How layouts work" expandable information on /admin/structure/layouts.
PR updated to:
- Use
<details>instead of<fieldset> - Move the PHP codes below the form submit button
- Add the PHP codes to other forms as well:
- 'Localize' tab for date formats
- 'Logging and errors' form (
/admin/config/development/logging) - Views' date fields (only visible when date format set to 'custom')
Many thanks for updating. Still love it, although I find it a bit odd that the help for a form item appears sort of outside the form.

Are we doing it that way somewhere else in core?