Nested template with field mapping

Created on 17 August 2023, 10 months ago
Updated 8 February 2024, 5 months ago

Hi, I'd like to provide a nested template for my content type, with field mapping. Basically this:

[
    ["core/group", {"className": "header-container"}, [
        ["drupal/simple-text", {"placeholder": "Insert title","tag":"h1", "mappingFields": [{"field": "title"}]}],
        ["text/gb-icon", {}]
    ]]
]

So, a group that wraps two blocks, where one of the nested blocks is mapped to the title. This creates the correct structure, and also the Gutenberg UI reports that the simple-text block is mapped correctly. However, on save, we get the error:

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null

If we remove the wrapping group, it works as it should. I'm guessing this is simply not supported, but also seems useful to have (at least in my case here). Alternative approaches also appreciated :)

✨ Feature request
Status

Active

Version

2.7

Component

Code

Created by

πŸ‡³πŸ‡΄Norway vegardjo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @vegardjo
  • πŸ‡³πŸ‡΄Norway vegardjo

    Seems like nested templates also have a problem if you add a dynamic block (block rendered with template) to it. In the case below where text/gb-orgmanager is a dynamic block, the block will only render in edit mode, and not show when you save. If it's not a dynamic block it works fine.

    [
        ["core/group", {"className": "header-container"}, [
            ["drupal/simple-text", {"placeholder": "Insert title","tag":"h1"}],
            ["text/gb-orgmanager", {}]
        ]]
    ]
    
Production build 0.69.0 2024