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

Bugfix/12539 fields removed from layout null vals #12578

Merged
merged 5 commits into from Feb 2, 2023

Conversation

i-just
Copy link
Contributor

@i-just i-just commented Jan 25, 2023

Description

If you add a custom field to a layout, populate that field with a value and then remove that field from the layout, if you try to get that value via a template, it will still be returned even though the field is no longer part of the layout. In terms of more complex fields (e.g. Money field for Craft 4, the value will be returned as string/number depending on your PHP version, and not as a Money field).

This PR sets custom field values for fields that are not part of the current layout as null.
The same applies to eager-loaded elements - only get them if they’re part of the layout (or if there’s no layout).

This can be merged into Craft 4 too.

Related issues

#12539

@i-just i-just marked this pull request as ready for review January 26, 2023 14:05
@i-just i-just requested a review from a team as a code owner January 26, 2023 14:05
@michtio
Copy link
Contributor

michtio commented Jan 28, 2023

Thank you @i-just , this seems like the perfect solution! 🙌🏻

@brandonkelly brandonkelly self-requested a review as a code owner February 2, 2023 22:18
@brandonkelly brandonkelly merged commit 5679736 into v3 Feb 2, 2023
@brandonkelly brandonkelly deleted the bugfix/12539-fields-removed-from-layout-null-vals branch February 2, 2023 22:18
@brandonkelly
Copy link
Member

Craft 3.7.64 and 4.3.7 have been released with the fix for this.

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.

None yet

4 participants