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

[BUG] DateTime fields are always considered "dirty" #7404

Closed
lindseydiloreto opened this issue Jan 20, 2021 · 2 comments
Closed

[BUG] DateTime fields are always considered "dirty" #7404

lindseydiloreto opened this issue Jan 20, 2021 · 2 comments
Labels

Comments

@lindseydiloreto
Copy link
Contributor

Description

When you save an Entry, the DateTime fields are always considered "dirty", even if the DateTime value did not change.

Steps to reproduce

  1. Create a DateTime field.
  2. Create an Entry with that field.
  3. Save the Entry with a normal DateTime value...

datetime@2x

  1. Add this event to your module...
Event::on(
    Entry::class,
    Entry::EVENT_AFTER_SAVE,
    function (ModelEvent $e) {
        /* @var Entry $entry */
        $entry = $e->sender;

        Craft::dd($entry->getDirtyFields());

    }
);
  1. Resave the entry.
  2. You'll notice that the DateTime fields are always considered "dirty", even if the value didn't change.

Additional info

  • Craft version: Craft Pro 3.5.17.1
  • PHP version: 7.4.9
  • Database driver & version: MySQL 5.5.5
@brandonkelly
Copy link
Member

Thank for reporting that! Just fixed for the next release.

@lindseydiloreto
Copy link
Contributor Author

Beautiful, thanks @brandonkelly! 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants