Form type to represent entity relation

In Symfony 4.4 application, I have a OneToOne relation between 2 entities BaseWord (with 2 fields : id and alias) and DeWord (with 3 fields : id, value, baseWord). baseWord field represents an instance of BaseWord entity.

To create DeWord instances, I used form builder

    ->add('baseWord', EntityType::class, [
        'class' => BaseWord::class,
        'choice_label' => 'alias',

And passing the DeWord entity from the controller

$deWord = new DeWord();
$form = $this->createForm(DeWordType::class, $deWord);

This solution may work but I have millions of baseWord entities and the SELECT generated in the form slows my application. So I want to use just an input to represent the baseWord field of the DeWord object. How can I do that ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *