title: Symfony on click adding a form row
body: <p>I'm trying to make a form with Symfony to be able to adding new row by clicking button. I can't use SubmitType class because after submit symfony can't add new row. ButtonType class doesn't have a basic function isClicked(). Here is my Form:</p>
  <pre><code>&lt;?php
  
  namespace App\Form;
  
  use App\Entity\Team;
  use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  use Symfony\Component\Form\Extension\Core\Type\ButtonType;
  use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  use Symfony\Component\Form\Extension\Core\Type\EmailType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\FormEvent;
  use Symfony\Component\Form\FormEvents;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  
  final class TeamFormType extends AbstractType
  {
  
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('teamName', TextType::class, [
                  'label' =&gt; false,
                  'attr' =&gt; array(
                      'placeholder' =&gt; 'Wpisz Nazwe Drużyny'
                  )
              ])
              -&gt;add('teamCity', TextType::class, [
                  'label' =&gt; false,
                  'attr' =&gt; array(
                      'placeholder' =&gt; 'Wpisz Nazwe Miasta'
                  )
              ])
              -&gt;add('teamCoach', TextType::class, [
                  'label' =&gt; false,
                  'attr' =&gt; array(
                      'placeholder' =&gt; 'Wpisz Imie i Nazwisko Trenera'
                  )
              ]);
          $builder-&gt;addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){
              $form = $event-&gt;getForm();
  
              for ($i = 1; $i &lt;= 6; $i++) {
                  $name = 'zawodnik' . $i .'';
                  $form-&gt;add($name, TextType::class, [
                      'mapped' =&gt; false,
                      'label' =&gt; false,
                      'attr' =&gt; array(
                          'placeholder' =&gt; 'Imie i Nazwisko Zawodnika'
                      )
                  ]);
              }
              $form-&gt;add('agreeTerms', CheckBoxType::class, [
                  'mapped' =&gt; false,
                  'required' =&gt; true,
                  'label' =&gt; 'Zaakceptuj regulamin'
              ])
              -&gt;add('Submit', SubmitType::class, [
                  'label' =&gt; 'Wyślij Zgłoszenie'
              ])
              -&gt;add('addRow', ButtonType::class, [
                  'label' =&gt; 'Dodaj zawodnika'
              ]);
          });
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; Team::class,
              'csrf_protection' =&gt; true,
              'csrf_field_name'=&gt; '_token',
              'csrf_token_id' =&gt; 'team_item'
          ]);
      }
  }
  </code></pre>
  <p>And Controller :</p>
  <pre><code>&lt;?php
  
  
  namespace App\Controller;
  
  
  use App\Form\TeamFormType;
  use Doctrine\DBAL\Types\TextType;
  use Doctrine\ORM\EntityManagerInterface;
  use http\Env\Request;
  use http\Env\Response;
  use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  
  class FormsController extends AbstractController
  {
      public function createTeamForm(Request $request, EntityManagerInterface $entityManager) :Response
      {
          $teamEntity = new Team();
          $form = $this-&gt;createForm(TeamFormType::class);
          $form-&gt;handleRequest($request);
          if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              if($form-&gt;get('addRow')-&gt;isClicked()) {
                  $form-&gt;add('something', TextType::class, [
                      'label' =&gt; false,
                      'attr' =&gt; array(
                          'placeholder' =&gt; 'Imie i Nazwisko zawodnika.'
                      )
                  ]);
              }
  
              $entityManager-&gt;persist($teamEntity);
              $entityManager-&gt;flush();
  
              $this-&gt;addFlash('success', 'Pomyślnie Utworzono Drużyne');
              return $this-&gt;redirectToRoute('index');
          }
      }
  }
  </code></pre>
  <p>Anyone have a idea to create button like that ?</p>