Field mapping works great, and with the new attribute and property params it's even more flexible. However we encountered an issue trying to solve a use case for a client. We wanted to map a block which contains a set of inner blocks. We had populate a field with rich text content from this block. This is practically not doable with the regex finding the mappingFields elements since it stops on the first closing block.

Comments

mnlund created an issue. See original summary.

mnlund’s picture

StatusFileSize
new2.35 KB
mnlund’s picture

Status: Active » Needs review
glardup’s picture

I have the same problem.
I have a schema with a title (simple-text), subtitle (simple-text), intro (section) and body (section):

[
["drupal/simple-text", {"placeholder": "Title","tag":"h1", "mappingFields": [{"field": "title"}]}],
["drupal/simple-text", { "placeholder":"Subtitle", "tag":"h2", "mappingFields": [{"field": "field_subtitle"}] }],
["drupal/section", { "placeholder":"Intro", "mappingFields": [{"field": "field_intro"}] }],
["drupal/section", {"placeholder":"Page content" }]
]

I applied your patch but now I have 2 new problems:
- The subtitle is merged with the body field (before the wp-block-drupal-section)
- The intro looses it's paragraphs: they are merged into one

szeidler’s picture

Status: Needs review » Active

The patch does not apply anymore for the 8.x-2.x branch, since the BlockParser has been refactored drastically. From the first glance it seems to support recursive block mapping. Can someone test and confirm this?

kiss.jozsef’s picture

StatusFileSize
new1.38 KB

There was no support for innerblocks , the BlockParser add the innerblocks correctly but when saving the data to the mapped field only the top level innerHTML is taken in account and that is empty ... maybe this isn't the best approach we might need to alter the BlockParser so the top level innerHTML contains all children innerHTML also but for now the attached patch fixes the issue

szeidler’s picture

Status: Active » Needs review

marcofernandes’s picture

Status: Needs review » Fixed
marcofernandes’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.