title: Symfony2: Where to inject translation_domain in Form Component
body: <p>I create a form using the <em>form component</em> of Symfony 2.
  As the validation errors are translated in different translation domains, I want to inject this information as an option (translation_domain) during creation of the form, but dont find the right (successful) spot where to set... Any hints?</p>
  
  <p>I use a custom type for bundling my form informations. </p>
  
  <p>My custom type class:</p>
  
  <pre><code>use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  use Symfony\Component\Validator\Constraints\Collection;
  use Symfony\Component\Validator\Constraints\NotBlank;
  
  class LoginType extends AbstractType
  {
  
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $collectionConstraint = $collectionConstraint = new Collection(array(
              'password' =&gt; array(new NotBlank(array('message' =&gt; 'custom.error.blank'))),
              'username' =&gt; array(new NotBlank(array('message' =&gt; 'custom.error.blank')))
          ));
  
          $resolver-&gt;setDefaults(array(
              'constraints' =&gt; $collectionConstraint
          ));
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder-&gt;add('username', 'text', array(
              'max_length'        =&gt; 250,
              'trim'              =&gt; true
          ));
          $builder-&gt;add('password', 'password', array(
              'max_length'        =&gt; 250,
              'trim'              =&gt; true
          ));
      }
  
      public function getName()
      {
          return 'login';
      }
  }
  </code></pre>
  
  <p>relevant code snippets on form creation in controller:</p>
  
  <pre><code>$loginForm = $this-&gt;createForm(new LoginType(), $loginDefaultData);
  
  $loginForm-&gt;bind($request);
  
  [...]
  
  return $this-&gt;render(
      'MyBundle:SubFolder:login.html.twig',
      array(
          'loginForm' =&gt; $loginForm-&gt;createView()
      )
  );
  </code></pre>