title: EasyAdmin 3 : Nested forms
body: <p>I'm trying to embed forms into forms. In my case :  I want to embed Period and Price form into Offer form into Poi form. The architecture :</p>
  <ul>
  <li>Poi form
  <ul>
  <li>Offer form
  <ul>
  <li>Price form</li>
  <li>Period form</li>
  </ul>
  </li>
  </ul>
  </li>
  </ul>
  <p>Relations:</p>
  <ul>
  <li>Poi entity has relation OneToMany with Offer entity</li>
  <li>Offer entity has relation OneToMany with Price entity and ManyToMany with Period
  entity.</li>
  </ul>
  <p>I've been looking for solution for couple of days and I really need help, so if someone could help me it will be great.</p>
  <p><strong>1. First test : usage of CollectionField</strong>
  In my PoiCrudController :</p>
  <pre class="lang-php prettyprint-override"><code>public function configureFields(string $pageName): iterable {
      $offers = CollectionField::new('offers')
              -&gt;setFormTypeOptions([
                  'delete_empty' =&gt; true,
                  'by_reference' =&gt; false,
              ])
              -&gt;setEntryIsComplex(false)
              -&gt;setCustomOptions([
                  'allowAdd' =&gt; true,
                  'allowDelete' =&gt; true,
                  'entryType' =&gt; 'App\Form\OfferType',
                  'showEntryLabel' =&gt; false,
              ]),
  </code></pre>
  <p>In OfferType :</p>
  <pre class="lang-php prettyprint-override"><code>class OfferType extends AbstractType {
  
      public function buildForm(FormBuilderInterface $builder, array $options) {
      
          $builder
              -&gt;add('description', CollectionType::class, array(
                  'allow_add' =&gt; true,
                  'allow_delete' =&gt; true,
                  'delete_empty' =&gt; true,
                  'by_reference' =&gt; false,
                  'entry_type' =&gt; TextEditorType::class,
                  'entry_options' =&gt; [
                    'label' =&gt; false,
                  ],
                  'label' =&gt; 'Description',
                ))
  
              -&gt;add('createdAt')
              -&gt;add('updatedAt')
              -&gt;add('periods')
              -&gt;add('poi')
          ;
      }
  }
  </code></pre>
  <p><strong>ERROR MESSAGE =&gt; The &quot;App\Entity\Poi&quot; entity has a repositoryClass set to &quot;App\Entity\PoiRepository&quot;, but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with &quot;doctrine.repository_service&quot;.</strong></p>
  <p>If I replace <code>'entryType' =&gt; 'App\Form\OfferType',</code> with <code>'entryType' =&gt; 'App\Form\PoiType' in PoiCrudController,</code> and add this code in PoiType :</p>
  <pre class="lang-php prettyprint-override"><code>class PoiType extends AbstractType {
  
      public function buildForm(FormBuilderInterface $builder, array $options) {
      
          $builder
              -&gt;add('offers', CollectionType::class, array(
                  'allow_add' =&gt; true,
                  'allow_delete' =&gt; true,
                  'delete_empty' =&gt; true,
                  'by_reference' =&gt; false,
                  'entry_type' =&gt; TextType::class, // cette ligne pose problème
                  'entry_options' =&gt; [
                    'label' =&gt; false,
                  ],
                  'label' =&gt; 'Offres',
                ))
  </code></pre>
  <p>Then the Poi form is nested into Poi form where the field 'offer' appears.
  If I replace <code>'entry_type' =&gt; TextType::class</code> with <code>'entry_type' =&gt; TextEditorType::class,</code> a new error appears :</p>
  <p><strong>ERROR MESSAGE : Impossible to access an attribute (&quot;customOptions&quot;) on a null variable.
  in vendor\easycorp\easyadmin-bundle\src\Resources\views\crud\form_theme.html.twig (line 424)
  {% set numOfRows = form.vars.ea_crud_form.ea_field.customOptions.get('numOfRows') %}</strong></p>
  <p><strong>2. Second test : usage of CollectionField</strong></p>
  <p>In PoiCrudController :</p>
  <pre class="lang-php prettyprint-override"><code>    CollectionField::new('offers', 'Offres')
                  -&gt;allowAdd() 
                  -&gt;allowDelete()
                  -&gt;setEntryIsComplex(true)
                  -&gt;setEntryType(OfferCrudController::class)
              -&gt;setFormTypeOptions([
                  'by_reference' =&gt; 'false' 
              ]),
  </code></pre>
  <p><strong>ERROR MESSAGE =&gt; Could not load type &quot;App\Controller\Admin\OfferCrudController&quot;: class does not implement &quot;Symfony\Component\Form\FormTypeInterface.</strong>
  My forms implement AbstractType so...</p>
  <p><strong>3. Third test : usage of AssociationField</strong></p>
  <p>In PoiCrudController :</p>
  <pre class="lang-php prettyprint-override"><code>    AssociationField::new('offers')
                  -&gt;setFormTypeOptions([
                      'by_reference' =&gt; false,
                      'multiple' =&gt; true,
                      'allow_add' =&gt; true
                  ]),
  </code></pre>
  <p><strong>ERROR MESSAGE =&gt; An error has occurred resolving the options of the form &quot;Symfony\Bridge\Doctrine\Form\Type\EntityType&quot;: The option &quot;allow_add&quot; does not exist</strong>
  =&gt;Issue #3528 [https://github.com/EasyCorp/EasyAdminBundle/issues/3528][2]</p>