Skip to content

Backend preview fails for content elements without header field #516

@robinson2

Description

@robinson2

Description

Backend preview rendering fails for Content Blocks content elements that do not define the core header field.
When a content element omits TYPO3/Header and therefore has no header field in its TCA schema, the page module preview crashes with:
The field "header" is not defined for the TCA schema "tt_content.my_element".
This seems to happen when Content Blocks falls back to TYPO3's default header preview rendering.

To Reproduce

  1. Create a Content Block content element without TYPO3/Header, using the following minimal config.yaml (adjust paths/extension as needed):
name: my/element
typeName: my_element
group: default
prefixFields: true
prefixType: full
basics:
  - TYPO3/Appearance
  - TYPO3/Links
fields:
  -
    identifier: bodytext
    useExistingField: true
  1. Add the element to a page.
  2. Open the TYPO3 layout module in the backend.
  3. Observe the exception:
    The field "header" is not defined for the TCA schema "tt_content.my_element".

Expected behavior
The backend preview should render without an exception when a content element intentionally has no header field.

If no custom Header section is provided, Content Blocks should either render an empty preview header or safely fall back only when the current TCA schema supports the field used by TYPO3's default preview renderer.

TYPO3 Version
14.3.0

Content Blocks Version
TER version 2.3.3

Workaround:

Explicitly define an empty Header section in templates/backend-preview.fluid.html:

<html data-namespace-typo3-fluid="true">
<f:layout name="Preview"/>
<f:section name="Header"></f:section>

Possible cause / proposal:

In Classes/Backend/Preview/PreviewRenderer.php, renderPageModulePreviewHeader() catches missing preview sections and then calls $this->standardContentPreviewRenderer->renderPageModulePreviewHeader($item). For content elements without a header field, TYPO3's StandardContentPreviewRenderer may resolve the record label field (header) via the Record/TCA schema API and throw TYPO3\CMS\Core\Schema\Exception\UndefinedFieldException.
Consider guarding or wrapping the standard header fallback so that UndefinedFieldException yields an empty header preview instead of breaking the backend.

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