Skip to content

[6.x] Fix default values and fieldtype meta after saving entries and terms - #15427

Open
duncanmcclean wants to merge 6 commits into
6.xfrom
publish-form-after-save
Open

[6.x] Fix default values and fieldtype meta after saving entries and terms#15427
duncanmcclean wants to merge 6 commits into
6.xfrom
publish-form-after-save

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Sep 8, 2026

Copy link
Copy Markdown
Member

This pull request fixes two issues with the publish form after saving an entry or term and continuing to edit.

Firstly, it fixes an issue where default values weren't applied to fields that had been saved empty (for example, a grid hidden behind a toggle with always_save: false), until the Stache was cleared.

This was happening because Entry::fileData() and Term::fileData() strip null and empty values before writing to disk, but the in-memory object (which is what the save response is built from, and what the Stache caches) keeps them. A hidden grid is processed to [], which isn't null, so Field::preProcess() never fell back to the field's default.

This PR fixes it by mirroring the writer's rule when extracting publish form values: empty values are dropped for root entries and default-locale terms. Localizations are left alone since explicit nulls are meaningful there.

Secondly, it fixes an issue where relationship values set in an EntrySaving or TermSaving listener rendered as broken items after "Save & continue editing", until the page was reloaded.

This was happening because the save pipeline re-applied the response's values, but nothing refreshed the fieldtype meta, so the Relationship fieldtype had no item data for the newly added IDs.

This PR fixes it by returning meta from the entry and term update endpoints and applying it in the save pipeline alongside the values.

The same missing meta was also behind #15418: a conditionally hidden nested Replicator with default: rows gets fresh row IDs on every request, so after saving, the Assets fieldtypes inside those rows couldn't find their meta and threw, leaving the Control Panel unresponsive until a hard refresh.

Fixes #11355
Fixes #11396
Fixes #15418
Fixes #15428
Replaces #11356

duncanmcclean and others added 3 commits September 8, 2026 13:04
the file writer drops empty values from root entries and default-locale terms, but the in-memory object keeps them, so `Field::preProcess()` never fell back to the default until the stache was cleared. mirror the writer's rule when extracting publish form values.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EmQ7DBwRHtNLUej3bbyMQW
return `meta` from the entry and term update endpoints and apply it in the save pipeline alongside the values, so relationship items added during `EntrySaving`/`TermSaving` render correctly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EmQ7DBwRHtNLUej3bbyMQW
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EmQ7DBwRHtNLUej3bbyMQW

@jasonvarga jasonvarga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PHP half looks right to me — ExtractsFromEntryFields and ExtractsFromTermFields mirror Entry::fileData()'s isRoot() conditional and Term::fileData()'s default-locale-only stripping precisely. I also confirmed the term restructure doesn't lose in-memory TermSaving changes, since LocalizedTerm::data() and inDefaultLocale()->data() both read through to the same underlying Term.

One issue on the JS side that needs fixing before this goes in — the wholesale setMeta() clobbers client-owned slug meta. Details inline.

Non-blocking: both new PHP tests only cover the root/default-locale branch, so nothing exercises the localization side of the new isRoot() ternary.

Comment thread resources/js/components/ui/Publish/SavePipeline.js
@jasonvarga
jasonvarga dismissed their stale review September 9, 2026 14:54

Changes were made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants