Skip to content

Conversation

@aerni
Copy link
Contributor

@aerni aerni commented Jun 18, 2025

This PR closes #118 and introduces fixes and improvements to how the computed timezone field is handled.

🐛 Bug 1: Unaugmented Raw Value

Problem

If the blueprint doesn't contain a timezone field, but the entry has a timezone value, the computed field would return the raw $value directly. This bypasses augmentation and could lead to unexpected behavior.

Solution

Before returning an existing $value, we now check if the blueprint has a timezone fieldtype that can handle augmentation.

  • If it exists, return the $value as-is (it will be properly augmented).
  • If it doesn’t, create a timezone field on the fly and return the augmented value.

🐛 Bug 2: Double value() Call

Problem

Calling value() twice causes the raw value to be set to the augmented value, which is unintended behavior.

return $tzField
->setValue($timezone)
->augment()
->value()
->value();

CleanShot 2025-06-18 at 17 14 25@2x

Solution

Ensure value() is only called once.

✨ Other Improvements

  • Creating the timezone field on the fly is now simpler and no longer requires the field to exist in the blueprint.
  • This allows developers to remove the timezone field from the blueprint entirely if they don’t want to store the timezone value.
    • In this case, the system will fall back to the default timezone set in the config.
    • Note: Changing the config would retroactively change the timezone for all such entries.
  • If consistency is preferred without exposing the field, developers can add visibility: hidden to the blueprint field instead.

@edalzell edalzell changed the title Betterify computed timezone field Improve computed timezone field Aug 29, 2025
@edalzell edalzell changed the title Improve computed timezone field Timezone field not required in blueprint Aug 29, 2025
@edalzell edalzell merged commit 43e0da6 into transformstudios:main Aug 29, 2025
6 checks passed
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.

Make the timezone field not required

2 participants