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

OneToMany relation generates no field in form #351

Open
devbieres opened this issue Jul 4, 2020 · 1 comment
Open

OneToMany relation generates no field in form #351

devbieres opened this issue Jul 4, 2020 · 1 comment

Comments

@devbieres
Copy link

devbieres commented Jul 4, 2020

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:

  • [EN - FR - IT] --> RelationEntityA,
  • [DE - ES] --> RelationEntityB,
  • [...] --> ?

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

  • One entity implementing TranslatableInterface and using TranslatableTrait,
  • A translation entity implementing TranslationInterface and using TranslationTrait,
    • This entity has a relation OneToMany with a third entity which is not translated (a simple entity),
  • One basic form for the main entity containing ->add('translations', TranslationsType::class)

Steps to reproduce

  • Implementing the entities,
  • Show the form in a view.

Expected results

For the relation entity have a select field.

Actual results

No field.

@devbieres
Copy link
Author

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.

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

1 participant