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

[5.x]: Setting field values in Entry::EVENT_BEFORE_SAVE doesn't work when $firstSave is true #15369

Closed
boboldehampsink opened this issue Jul 17, 2024 · 1 comment
Assignees
Labels

Comments

@boboldehampsink
Copy link
Contributor

What happened?

Description

I have an Entry::EVENT_BEFORE_SAVE event in which I do:

$entry->setFieldValues([
    'latitude' => $coords['lat'],
    'longitude' => $coords['lng'],
]);

This works when updating entries, but not for the case where $entry->firstSave is true.

Steps to reproduce

  1. Create an event listener that sets entry field values.

Expected behavior

It should work on first save.

Actual behavior

The first time saving it doesn't work, on updating it does.

Craft CMS version

5.2.6

PHP version

8.3

Operating system and version

No response

Database type and version

PostgreSQL 16

Image driver and version

No response

Installed plugins and versions

@brandonkelly
Copy link
Member

Craft 5.2.9 is out with a fix for this. Thanks for reporting!

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

3 participants