# Edit the translation of a dynamic content

**URL:** <https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [May 18, 2023, 9:27am UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062 "2023-05-18T09:27:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaser](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yaser](https://forum.mautic.org/u/yaser)\
**Post date:** [May 18, 2023, 9:27am UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062/1 "2023-05-18T09:27:19Z")

</div>

My Mautic version is:: 4.4.8  
My PHP version is: 8.1.6

My problem is:  
I have created a Dynamic content, and set it as a translation for another one.  
when I try to edit the translation, it keeps give me an error, and I cant edit it or clone it ether any way.

These errors are showing in the log:  
Uncaught PHP Exception Doctrine\DBAL\Exception: "An exception occurred while executing 'SELECT d0\_.id AS id\_0, d0\_.name AS name\_1, d0\_.lang AS lang\_2 FROM dynamic\_content … etc.

---

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [May 19, 2023, 1:24pm UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062/2 "2023-05-19T13:24:32Z")

</div>

I tested it with 4.4.7 and PHP 8.0 … no issues. PHP 8.1 is not supported yet. Give it a try with PHP 8.0 maybe. If I find the time, I will update my instance today and test 4.4.8 and PHP 8.0.

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/9/98f3449c8dec98d41c384ef2f461b9f63bb7b7c4.png)

---

<div class="post-metadata">

**Author:** ![miki](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/miki/32/12678_2.png) [@miki](https://forum.mautic.org/u/miki)\
**Post date:** [April 29, 2024, 12:20pm UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062/3 "2024-04-29T12:20:25Z")

</div>

It’s still an issue. You can see the dynamic content list, but you can not edit or view the translation variants.  
Mautic version is:: 4.5 (but I checked the code of 4.4.11 too and I can’t see any changes in the Dynamic content bundle)  
PHP version is: 8.0.27-fpm

I found what the problem is, but I don’t know why it happens and how I can solve.  
The problem: The DynamicContentModel’s getLookupResults function’s $filter parameter is array like this:  
array(5) {  
[“type”]=\> string(14) “dynamicContent”  
[“filter”]=\> array(38) {  
[“ **initializer** ”]=\> int(1)  
[“ **cloner** ”]=\> int(1)  
[“ **isInitialized** ”]=\> int(0)

and that`s why the called getDynamicContentList function of the DynamicContentRepository gives an error 500, because this fails:

if (is\_array($search)) {  
$search = array\_map(‘intval’, $search);  
$q-\>andWhere($q-\>expr()-\>in(‘e.id’, ‘:search’))  
-\>setParameter(‘search’, $search);  
(Exception Doctrine\DBAL\Exception  
"An exception occurred while executing  
‘SELECT d0\_.id AS id\_0, d0\_.name AS name\_1, d0\_.lang AS lang\_2  
FROM dynamic\_content d0\_  
WHERE d0\_.id IN (?)  
AND d0\_.translation\_parent\_id IS NULL  
AND d0\_.id NOT IN (?)  
ORDER BY d0\_.name ASC’  
with params [{“ **initializer** ”:1,  
“ **cloner** ”:1,  
“ **isInitialized** ”:0,  
“\u0000Mautic\DynamicContentBundle\Entity\DynamicContent\u0000id”:16,  
“\u0000Mautic\DynamicContentBundle\Entity\DynamicContent\u0000name”:0,  
…  
…  
)

The same flow works when it’s about the emails and I can’t see any differences.  
Any idea how to solve this? Thanks in advance! 🙂

---

<div class="post-metadata">

**Author:** ![miki](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/miki/32/12678_2.png) [@miki](https://forum.mautic.org/u/miki)\
**Post date:** [May 2, 2024, 5:33pm UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062/4 "2024-05-02T17:33:39Z")

</div>

Can anyone confirm that this feature works under version 5? (Viewing and editing a language version of a dynamic content)  
Is it worth to upgrade?

---

<div class="post-metadata">

**Author:** ![miki](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/miki/32/12678_2.png) [@miki](https://forum.mautic.org/u/miki)\
**Post date:** [June 12, 2024, 9:53am UTC](https://forum.mautic.org/t/edit-the-translation-of-a-dynamic-content/28062/5 "2024-06-12T09:53:43Z")

</div>

I found the reason of the problem and I have a possible solution for it.

So the problem again:  
When you have a dynamic content with language variants, you can see the dynamic content list (parent, language variants), but **you can not edit the translation variants**.

The reason of the problem:

In the EntityLookupChoiceLoader (\app\bundles\CoreBundle\Form\ChoiceLoader\EntityLookupChoiceLoader.php) class the getChoices method needs the $data, but that is always null.  
So the method grabs the $this-\>selected

```auto
if (null === $data) {
    $data = $this->selected;
}

```

That comes from the onFormPostSetData method of the class

```auto
public function onFormPostSetData(FormEvent $event)
{
    $this->selected = (array) $event->getData();
}

```

While debugging I can see when an Email entity has a language variant (Mautic\EmailBundle\Entity\Email) the $event-\>getData() is always an integer - the ID of the parent of the selecte language variant.  
But when it`s a dynamic content entity (Mautic\DynamicContentBundle\Entity\DynamicContent) the $event->getData() is an object. That`s why we have a problem and that`s because of some Doctrine lazy load issue.

My solution is a fix in the onFormPostSetData method.

```auto
public function onFormPostSetData(FormEvent $event)
{
    if (is_object($event->getData()) && $event->getData() instanceof \Doctrine\ORM\Proxy\Proxy) {
        $event->getData()->__load();

        $event->setData($event->getData()->getId());
    }

    $this->selected = (array) $event->getData();
}

```

If anyone has a better solution, let me know please! 🙂

I tested the Mautic versions from 4.4.5 till 4.4.12 - every of them has the same problem, but I don`t know anything about the Mautic 5 versions.
