title: Symfony2 - Set a selected value for the entity field
body: <p>I'm trying to set a selected value inside an entity field. In accordance with many discussions I've seen about this topic, I tried to set the <code>data</code> option but this doesn't select any of the values by default:</p>
  
  <pre><code>class EventType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('place', 'entity', array(
                  'class' =&gt; 'RoyalMovePhotoBundle:Place',
                  'property' =&gt; 'name',
                  'empty_value' =&gt; "Choisissez un club",
                  'mapped' =&gt; false,
                  'property_path' =&gt; false,
                  'data' =&gt; 2
              ))
              -&gt;add('begin')
              -&gt;add('end')
              -&gt;add('title')
              -&gt;add('description')
          ;
      }
  
      // ...
  }
  </code></pre>
  
  <p>By looking for more I've found that some people had to deactivate the form mapping to the entity. That seems logical so I tried to add <code>'mapped' =&gt; false</code> to the options, without success...</p>
  
  <p>If it can help, here's my controller:</p>
  
  <pre><code>class EventController extends Controller
  {
      // ...
  
      public function addAction()
      {
          $request = $this-&gt;getRequest();
          $em = $this-&gt;getDoctrine()-&gt;getManager();
  
          $event = new Event();
          $form = $this-&gt;createForm(new EventType(), $event);
  
          $formHandler = new EventHandler($form, $request, $em);
  
          if($formHandler-&gt;process()) {
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('success', "L'évènement a bien été ajouté.");
              return $this-&gt;redirect($this-&gt;generateUrl('photo_event_list'));
          }
  
          return $this-&gt;render('RoyalMovePhotoBundle:Event:add.html.twig', array(
              'form' =&gt; $form-&gt;createView()
          ));
      }
  }
  </code></pre>
  
  <p>And the <code>EventHandler</code> class:</p>
  
  <pre><code>class EventHandler extends AbstractHandler
  {
      public function process()
      {
          $form = $this-&gt;form;
          $request = $this-&gt;request;
  
          if($request-&gt;isMethod('POST')) {
              $form-&gt;bind($request);
  
              if($form-&gt;isValid()) {
                  $this-&gt;onSuccess($form-&gt;getData());
                  return true;
              }
          }
  
          return false;
      }
  
      public function onSuccess($entity)
      {
          $em = $this-&gt;em;
  
          $em-&gt;persist($entity);
          $em-&gt;flush();
      }
  }
  </code></pre>
  
  <p>I'm a bit stuck right now, is there anyone who got an idea?</p>