Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormType and multiple translation entity inheritance #26

Closed
alchy58 opened this issue Mar 6, 2021 · 1 comment
Closed

FormType and multiple translation entity inheritance #26

alchy58 opened this issue Mar 6, 2021 · 1 comment

Comments

@alchy58
Copy link

alchy58 commented Mar 6, 2021

Hello,

I have an entity Person which inherits a Thing entity, based on schema.org pattern.
I also have a PersonTranslation which inherits a ThingTranslation entity.

ThingTranslation entity declares the description attribute.
Person entityTranslation declares the jobTitle attribute.

Then, on the PersonType form type, using ->add('translations', TranslationsType::class works fine.

The issue is when I want to describe both fields. I get the error Field(s) 'jobTitle' doesn't exist in App\Thing\Entity\ThingTranslation.

In A2lix\AutoFormBundle\Form\Manipulato\DoctrineORMManipulator@getDataClass, the association mapping fails to detect the PersonTranslation class.

If I basically replace

return $this->doctrineORMInfo->getAssociationTargetClass($dataClass, $form->getName());
by return $dataClass.'Translation';, it works.

Do you think it can have drawbacks ?

I may be related to #17

Thank you a lot.

@tuxes3
Copy link

tuxes3 commented Feb 16, 2022

I ran into the same issue 👍

Your solution works in the Basic case, but the a2lix allows you to change the Translation class name.
This method can be overridden in the Translatable Entity.

public static function getTranslationEntityClass(): string{
    return static::class . 'Translation';
}

Have you found a workaround or fix?

*Edit:

return $dataClass::getTranslationEntityClass();

Would do it for all cases i think.

@webda2l webda2l closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants