Skip to content

[5.x]: Deeply nested Matrix blocks can trigger Invalid element UUID during field layout refresh #19096

@lekiq

Description

@lekiq

What happened?

Description

We are seeing repeated Craft CP failures when editors work with translated entries that contain deeply nested Matrix fields in blocks view mode.

The affected structure is roughly:

contentBlocks -> cards -> linkList / links

All of these are Matrix fields using viewMode: blocks.

From our logs, the failing request is always:

elements/update-field-layout

The error is:

yii\web\BadRequestHttpException: Invalid element UUID

The issue appears to happen when Craft tries to refresh the field layout for a nested Matrix entry, likely after a conditional field changes. In our case, the Card entry type has a Typ / cardType field that controls conditional fields such as linkList.

From checking Craft’s code, blocks mode renders nested Matrix entries as inline forms inside the parent form. With multiple nested Matrix levels, each block has its own form observer and can trigger elements/update-field-layout. That request sends the nested entry UUID, owner ID, field ID, type ID, and layout state. In the failing cases, Craft cannot resolve the nested UUID in the current owner/site/field context and returns Invalid element UUID.

Switching the same Matrix fields from blocks to cards avoided the issue in our local testing, because nested entries are then edited via card/slideout flow instead of deeply nested inline forms.

Relevant code paths we looked at:

craft\fields\Matrix::inputHtmlInternal()
craft\fields\Matrix::blockInputHtml()
craft\elements\NestedElementManager::getCardsHtml()
craft\controllers\ElementsController::actionUpdateFieldLayout()
craft\controllers\ElementsController::_element()

Craft version:

5.10.4.1

Steps to reproduce

  1. Create a Matrix field in blocks view mode, e.g. contentBlocks.
  2. Add a Matrix entry type that contains another Matrix field, e.g. cards, also in blocks view mode.
  3. Inside that nested Matrix entry type, add conditional fields controlled by an option/dropdown field, e.g. cardType.
  4. Add another nested Matrix field behind one of those conditions, e.g. links / linkList, also in blocks view mode.
  5. Edit a translated entry using this structure.
  6. Add or edit nested content under contentBlocks -> cards -> linkList.
  7. Change the conditional field, e.g. cardType.
  8. Observe the CP request to elements/update-field-layout.

Expected behavior

Craft should refresh the conditional field layout for the nested Matrix entry without losing track of the nested element.

The editor should be able to continue editing translated nested Matrix content normally.

Actual behavior

Craft returns a 400 Bad Request from:

elements/update-field-layout

With:

yii\web\BadRequestHttpException: Invalid element UUID

The editor cannot continue reliably because the nested field layout refresh fails.

Additional context

We saw this repeatedly in production logs for translated sites.

The relevant log pattern:

yii\web\BadRequestHttpException: Invalid element UUID
/admin/actions/elements/update-field-layout
vendor/craftcms/cms/src/controllers/ElementsController.php

Local mitigation tested:

Changing the nested Matrix fields from blocks to cards stopped the failing update-field-layout requests in our tests.

Craft Matrix docs mention that blocks renders nested entries inline, while cards, card grid, and index open nested entries separately:

https://craftcms.com/docs/5.x/reference/field-types/matrix.html#view-mode

Craft CMS version

5.10.4.1

PHP version

8.5.7

Operating system and version

No response

Database type and version

PostgreSQL 17.10

Image driver and version

Imagick 3.8.1 (ImageMagick 6.9.11-60)

Installed plugins and versions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions