I am using symfony 5.2 and Easyadmin 3. I try to implement translation with A2Lix bundle in easyadmin at that time i got error like:

The Doctrine type of the "translations" field is "4", which is not supported by EasyAdmin yet.

I have checked with Symfony EasyAdmin 3.x ManyToMany error when adding : The Doctrine type of the .... field is "4", which is not supported by EasyAdmin yet

But this case is different becuase i am implementing translation in easyadmin.

Can anyone Help me? How to solve it.

1

There are 1 answers

0
Yagnesh Makwana On BEST ANSWER

Finally i got a way to solve this issue.

I found solution from below link:

https://github.com/EasyCorp/EasyAdminBundle/issues/1621

Created a translation field:

namespace App\Admin\Field;

use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;

final class TranslationField implements FieldInterface
{
    use FieldTrait;

    public static function new(string $propertyName, ?string $label = null, $fieldsConfig = []): self
    {
        return (new self())
            ->setProperty($propertyName)
            ->setLabel($label)
            ->setFormType(TranslationsType::class)
            ->setFormTypeOptions(
                [
                    'default_locale' => '%locale%',
                    'fields' => $fieldsConfig,
                ]
            );
    }
}

After creating field implement in crud controller:

public function configureFields(string $pageName): iterable
    {
        $fieldsConfig = [
            'subject' => [
                'field_type' => TextareaType::class,
                'required' => true,
                'label' => 'Тема',
            ],
            'text' => [
                'field_type' => CKEditorType::class,
                'required' => true,
                'label' => 'Текст',
            ],
        ];

        return [
            TranslationField::new('translations', 'Переводы', $fieldsConfig)
                ->setRequired(true)
                ->hideOnIndex(),
            TextField::new('subject')->hideOnForm()->setLabel('Тема'),
            BooleanField::new('isActive')->setLabel('Активность'),
        ];
    }

This code will save time of anybody who face this kind of issue.