title: Symfony 4: Form as service, inject service : too few arguments
body: <p>I try to get service in my Form, following official instructions:
  <a href="https://symfony.com/doc/current/form/form_dependencies.html" rel="nofollow noreferrer">https://symfony.com/doc/current/form/form_dependencies.html</a></p>
  
  <p>this is my services.yaml:</p>
  
  <pre><code>services:
      # default configuration for services in *this* file
      _defaults:
          autowire: true      # Automatically injects dependencies in your services.
          autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
          public: false      
  class name
      App\:
          resource: '../src/*'
          exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
  class
      App\Controller\:
          resource: '../src/Controller'
          tags: ['controller.service_arguments']
  
  App\Service\:
      resource: '../src/Service/*'
  
  App\Form\:
      resource: '../src/Form/*'
  </code></pre>
  
  <p>my form look like this : </p>
  
  <pre><code>&lt;?php
  namespace App\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  
  use Doctrine\Common\Persistence\ObjectManager;
  
  use App\Entity\Contrat;
  use App\Entity\Society;
  use App\Entity\Client;
  use App\Form\DataTransformer\ClientToNumberTransformer;
  use App\Form\DataTransformer\SocietyToNumberTransformer;
  
  
  
  class ContratType extends AbstractType{
  
      private $manager;
  
      public function __construct(SocietyToNumberTransformer $manager){ // this is the breakpoint from error
          $this-&gt;manager = $manager;
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('...')
              ...
          ;
          // Old fashion way for testing only ...
          $builder-&gt;get('client')-&gt;addModelTransformer(new ClientToNumberTransformer($this-&gt;manager));
          $builder-&gt;get('society')-&gt;addModelTransformer(new SocietyToNumberTransformer($this-&gt;manager));
      }
  
      public function configureOptions(OptionsResolver $resolver){
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; Contrat::class,
          ));
      }
  </code></pre>
  
  <p>It's look-like pretty ... When i test this with postman I get this error : </p>
  
  <blockquote>
    <p>Too few arguments to function App\Form\ContratType::__construct(), 0
    passed in /code/vendor/symfony/form/FormRegistry.php on line 92 and
    exactly 1 expected</p>
  </blockquote>
  
  <p>I don't understand, i found my fomr in autowiring debug command :</p>
  
  <pre><code>php bin/console debug:autowiring
  </code></pre>
  
  <blockquote>
    <p>App\Form\ContratType<br>
    App\Form\DataTransformer\ClientToNumberTransformer<br>
    App\Form\DataTransformer\SocietyToNumberTransformer</p>
  </blockquote>
  
  <p>and the controller : </p>
  
  <pre><code>  public function addContrat(Request $request, FormData $formData){
  
          $em = $this-&gt;getDoctrine()-&gt;getManager('default');
  
          $data = $formData-&gt;getRequestData($request);
          var_dump($data);
  
          $contrat = new Contrat;
          $form = $this-&gt;factory-&gt;createBuilder(ContratType::class, $contrat)-&gt;getForm();
  
          $form-&gt;submit($data);
  
          if($form-&gt;isValid()){
              $em-&gt;persist($contrat);
              $em-&gt;flush();
  
              return $this-&gt;response(
                  $this-&gt;serialize(
                      $contrat, 
                      ['group1']
                  )
              );
          }
          return $this-&gt;response('error', 500);
      }
  </code></pre>
  
  <p>thx for your help.</p>