Skip to content

[5.x]: nested entries in a matrix field - slug gets unnecessarily incremented on the first save of the owner after adding nested entry #15672

@i-just

Description

@i-just

What happened?

Description

If you add a nested entry to a matrix field (where the matrix field has a URI format set) and then save the owner entry, the slug of the nested entry you just created will be incremented. For example, if the slug for the nested entry was test, then after saving the owner, it’ll be test-2.

(You can then edit the nested entry and remove the increment part, and it'll save just fine.)

Steps to reproduce

  1. Create a matrix field with the Entry URI Format set to, e.g. {owner.uri}/{slug} or about/{slug}.
  2. Create a section that has an entry type that uses this matrix field.
  3. Create an entry in this section (without content for the matrix field for now) and save it.
  4. Add an entry to the matrix field. Note that the slug will be correct at this point.
  5. Save the owner entry (from step 4). Open the nested entry created in step 5 and notice that the slug was incremented.

Expected behavior

Slug shouldn’t be incremented in this case.

Actual behavior

Slug is incremented.

Craft CMS version

5.4.1

PHP version

8.2

Operating system and version

No response

Database type and version

mysql 8

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions