- Issue created by @agentrickard
I have looked at other issues, and this seems unique, at least as I define it.
When using Layout Builder with a block that contains an ERR field, referenced entities are created and saved as if they were "real" content, rather than saving to tempstore.
Here's the call stack summary:
* LayoutBuilderSampleEntityGenerator::get() triggers entity creation
* Entities and saved in tempstore
$tempstore = $this->tempStoreFactory->get('layout_builder.sample_entity');
$entity = $entity_storage->createWithSampleValues($bundle_id);
// Mark the sample entity as being a preview.
$entity->in_preview = TRUE;
$tempstore->set("$entity_type_id.$bundle_id", $entity);
return $entity;
* This routine calls ContentEntityStorageBase::createWithSampleValues()
* That invokes $entity->get($field_name)->generateSampleItems();
* That calls FieldItemList::generateSampleItems()
$values[$delta] = $field_type_class::generateSampleValue($field_definition);
* Which invokes EntityReferenceRevisionsItem::generateSampleValue()
* Which calls an $entity_save() that ignore the tempstore.
The result are entities that are created and saved when Layout Builder is loaded.
Use the proper tempstore for entities created during generateSampleValue()
Rew
None
None
None
Active
1.0
Code