title: Symfony2: How to modify a form value before validation
body: <p>I have the following situation:</p>
  
  <ul>
  <li>a form field type <code>date</code></li>
  <li>a validation pattern like <code>dd.mm.YYYY</code></li>
  <li>a helper object that turns <code>12</code> into <code>12.07.2012</code> or <code>2.5</code> into <code>02.05.2012</code> etc.</li>
  </ul>
  
  <p><strong>My question is: Where do I call the method that transforms the input value?</strong></p>
  
  <p>When I call it from the <code>set</code>-method of the entity, the value actually gets changed. But when loading the form again (e.g. incomplete submit) the old value (like <code>2.5</code>) and not the transformed value (<code>2.5.2012</code>) is shown. Now, how do I tell the form, that the value has changed within the entity?</p>
  
  <p>Maybe there's also another way of doing it in-between:</p>
  
  <pre><code>$form-&gt;bindRequest($request);
  // do some fancy stuff here
  if ($form-&gt;isValid()) {}
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <p>This is from the <em>Entity</em>:</p>
  
  <pre><code>/**
   * @ORM\Column(type="datetime", nullable=true)
   * @Assert\DateTime()
   */
  protected $date_start;
  </code></pre>
  
  <p>This is from the <em>Type</em>:</p>
  
  <pre><code>$builder-&gt;add('date_start', 'datetime', array(
      'label' =&gt; 'Start Datum/Uhrzeit',
      'date_widget' =&gt; 'single_text',
      'time_widget' =&gt; 'single_text',
      'date_format' =&gt; 'dd.MM.yyyy',
      'with_seconds' =&gt; false,
      'required' =&gt; false,
  ));
  </code></pre>