Skip to content

default title format and first save of nested elements#19012

Merged
brandonkelly merged 6 commits into
5.xfrom
bugfix/18991-default-title-format
Jun 2, 2026
Merged

default title format and first save of nested elements#19012
brandonkelly merged 6 commits into
5.xfrom
bugfix/18991-default-title-format

Conversation

@i-just
Copy link
Copy Markdown
Contributor

@i-just i-just commented Jun 1, 2026

Description

In some cases, the title of the nested element with a default title format isn’t updated on the first full save.

What happens is: when the root Entry is saved, the ElementsController::actionApplyDraft() is called, and it’ll eventually get to NestedElementManager::duplicateNestedEntries(), which will save the element (Elements::_saveElementInternal()).
That'll trigger Entry::beforeSave() and finally Entry::updateTitle().

But when updateTitle() is called from beforeSave(), the canonical nested entry that’s being saved doesn’t have its final ID yet. So if you’re using pt-{object.id} as your titleFormat, the template will resolve to pt-.

Fixed by adding a new Element::afterNewRecordSaved() method.

Related issues

#18991

@i-just i-just requested a review from brandonkelly June 1, 2026 11:24
@brandonkelly brandonkelly merged commit 5b2e624 into 5.x Jun 2, 2026
2 checks passed
@brandonkelly brandonkelly deleted the bugfix/18991-default-title-format branch June 2, 2026 16:15
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.

2 participants