Search code examples
phpformssymfonynestedeasyadmin

EasyAdmin 3 - CRUD with nested form


I am trying to embed a subform to a form with EasyAdmin 3.

I have entity A that has a OneToOne relationship with entity B.

class entityA {
  
  private $id;

  private $name;

  //OneToOne with cascade persist
  private $entityB; 

}
class entityB {
  
  private $id;

  private $name;

  private $price;

}

In my Entity A CRUD Controller, how can I display the entity B form ?

public function configureFields(string $pageName): iterable
    {
        return [
            TextField::new('name'),
            // entity B form ?? (name, price)
        ];
    }

I tried CollectionType but it works only for...collection. It's not for OneToOne relations :(


Solution

  • TextField::new('entityB.name'),