CloneEntity sets the cloned entity as the event's entity

Created on 9 June 2025, about 1 month ago

Problem/Motivation

I have an entity type (Request) that includes a Paragraph field (Policy). When the user is presented with the creation form for that request, I want the form's paragraph field prefilled with a previously used policy. This is not desired if you are cloning a referenced field entity as it will set that entity as the form's entity.

Steps to reproduce

So I used the Entity prepare form event to clone the policy paragraph (I don't want to reuse the *same* paragraph). The problem is that CloneEntity contains the following code:

    if ($this->event instanceof ContentEntityPrepareForm) {
      $this->event->setEntity($newEntity);
    }

Proposed resolution - User interface changes

It would be nice if there were a checkbox to select - or even better decide based on the context.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇬🇷Greece larjohn

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

Comments & Activities

Production build 0.71.5 2024