Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use date field's own format to edit the resource #60

Merged
merged 4 commits into from
Jul 29, 2021

Conversation

Skullbock
Copy link
Contributor

Description

When editing a Date field, let's use the user defined format if set, or a sensible default if not

@duncanmcclean
Copy link
Member

I'm not sure I completely understand what the issue is here - do you have an example?

(thanks for these PRs by the way, I really appreciate it!)

@Skullbock
Copy link
Contributor Author

This fixes 2 issues:

  1. The default date format was laking the :s. This meant that any datetime stored in mysql would fail because carbon was trying to parse Y-m-d H:i and the date is stored as Y-m-d H:i:s
  2. While i was at it, since each date field in statamic allows for a particular date format to be used, i also thought to "pick that up" from the config and use it. A use case could be a date stored in a text field, or even a simpler DATE field that should be parsed as Y-m-d

@duncanmcclean
Copy link
Member

Cool 👍

One thing I've noticed is that if you don't have a format set on the date field in the blueprint, I seem to get a Trailing data error. As soon as I add one (Y-m-d H:i:s), it starts working.

The field in question is the created_at column on my model. Could that be happening just because it's a special timestamp field? Maybe it doesn't happen if you have a normal date or datetime field, I've not tested with those two yet.

Another quick thing: do you think you'd be up for writing a quick test to make sure everything works as you'd expect? If not, that's fine, I can have a go.

@Skullbock
Copy link
Contributor Author

I should've fixed that, and added a test with 3 cases ;)

Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me, thanks again!

@duncanmcclean duncanmcclean merged commit 726c5ea into statamic-rad-pack:2.1 Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants