title: Display new form field after user select something in select field
body: <p>I have made a simple form with Symfony form type</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $factory = $builder-&gt;getFormFactory();
      $domainsNamesTransformer = new DomainsNamesTransformer();
  
      $builder-&gt;add(
          $builder-&gt;create('domains', TextareaType::class, [
              'label' =&gt; 'form.names',
              'translation_domain' =&gt; 'global',
              'constraints' =&gt; [
                  new Assert\NotBlank(),
              ],
          ])
          -&gt;addModelTransformer($domainsNamesTransformer)
      );
  
      // Limit to user servers
      $builder-&gt;add('server', EntityServerType::class, [
          'user' =&gt; $options['user'],
          'nadmin_compliant' =&gt; true,
          'ip_network' =&gt; IpV4::NETWORK_PUBLIC,
          'required' =&gt; true,
          'constraints' =&gt; [
              new Assert\NotBlank(),
          ],
      ]);
  
      // Ask if user want a database
      $askDatabase = function (FormInterface $form, $server) {
          if ($server != null &amp;&amp; $server-&gt;getMysqlServer === true) {
              $form-&gt;add('database', CheckboxType::class, [
                  'label' =&gt; 'domain.form.associated_databases',
                  'translation_domain' =&gt; 'front',
                  'required' =&gt; false,
              ]);
          }
      };
  }
  </code></pre>
  
  <p>I'm trying to display a new field when the user select an option in the <code>server</code> field.
  So I have made a <code>eventListener</code> to do this but when I select an option, nothing append...</p>
  
  <pre><code>    $builder-&gt;addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($askDatabase) {
          $form = $event-&gt;getForm();
          $data = $event-&gt;getData();
  
          if (array_key_exists('server', $data)) {
              $askDatabase($form, $data['server']);
          }
      });
  </code></pre>
  
  <p>I also tried with <code>POST_SET_DATA</code> and <code>PRE_SUBMIT</code> but nothing append anyway.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The array key <code>server</code> exist inside <code>$data</code> because when I dump it, I get <code>null</code> at the loading of the page.</p>
  
  <p>Is this doable with <code>eventListener</code> or this is the wrong way to do this ?
  How can I do this ?</p>
  
  <p>Thanks for your help.</p>