Got an issue with my CloneNodeEventSubscriber's preClone function. I use it to wipe out or alter certain fields before cloning. It works great on text fields, select fields (setting a value), or booleans (setting the value to 'false'). The form is generally:
$cloned_entity = $event->getClonedEntity();
$cloned_entity->set('field_my_field','my_value');
Where I'm having a problem is with attempting to wipe out the content of paragraphs fields (entity reference revisions). None of these tricks seem to work:
unset($cloned_entity->field_my_paragraph);
$cloned_entity->get('field_my_paragraph')->removeItem(0);
$cloned_entity->set('field_my_paragraph',[]);
However, if I similarly try these tricks on $entity, and then run $entity->save();, the field empties out as I expect.
I tried following the debug trail to see what was going on, but as best I can tell, the changes to $cloned_entity get lost somewhere after the preClone is complete, in EntityCloneForm::submitForm().
Any hints or tricks to modify this kind of cloned content before it's saved? Has anyone tried this before?
Active
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.