a2lix / TranslationFormBundle

Ease translations with some dedicated Symfony form types
https://a2lix.fr/bundles/translation-form
MIT License
331 stars 138 forks source link

OneToMany relation generates no field in form #351

Open devbieres opened 4 years ago

devbieres commented 4 years ago

Hi,

I have a main entity with a translation. In the Translation Entity, there is a relation OneToMany with another entity. Several translated entities may be associated with same relation entities:

When rendering the form, there is no field for this relation.

Here is the definition of the relation :

**
* @ORM\OneToMany(targetEntity="App\Entity\SolutionImages", mappedBy="solutionTranslation", orphanRemoval=true)
* @var Collection
*/
private $solutionImages;

In the main entity type, I simply add

 ->add('translations', TranslationsType::class)

Thanks for your help.

Environment

Composer packages

$ composer show
a2lix/auto-form-bundle                       0.3.1   Automate form building
a2lix/translation-form-bundle                3.0.7   Translate your doctrine objects easily with some helps
knplabs/doctrine-behaviors                   v2.0.4  Doctrine Behavior Traits
symfony/form                                 v5.1.2  Symfony Form Component
symfony/framework-bundle                     v5.1.2  Symfony FrameworkBundle

PHP version

$ php -v
PHP 7.3.17-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Apr 19 2020 07:44:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.17, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.17-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.3, Copyright (c) 2002-2020, by Derick Rethans

Subject

Steps to reproduce

Expected results

For the relation entity have a select field.

Actual results

No field.

devbieres commented 4 years ago

For information, I have try to use a EntityType for this field :

 ->add('translations', TranslationsType::class, [
                'fields' => [
                    'label' => [ 'field_type' => TextType::class],
                    'description' =>  [ 'field_type' => TextareaType::class],
                    'solutionImages' => [
                        'field_type' => EntityType::class,
                        'class' => SolutionImages::class
                     ]
                ]
            ])

But it raised an error :

An error has occurred resolving the options of the form "Symfony\Bridge\Doctrine\Form\Type\EntityType": The options "allow_add", "entry_options", "entry_type" do not exist.