title: Symfony: Make a datetime form field really read-only
body: <p>I marked a datetime form field as read_only. Since this seams to have no effect I overruled the default twig template. This works fine.</p>
  
  <pre><code>{% block datetime_widget %}
      {% if read_only %}
          {{ value.date.year }}-{{ value.date.month }}-{{ value.date.day }} {{ value.time.hour }}:{{ value.time.minute }}
      {% else %}
          {{ parent() }}
      {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>This is the form type I'm using:</p>
  
  <pre><code>/**
   * @ORM\Entity
   */
  abstract class BusinessClass
  {
  
      /**
       * @ORM\Column(type="datetime")
       * @var \DateTime
       */
      private $created;
  
      /**
       * @return \DateTime
       */
      public function getCreated()
      {
          return $this-&gt;created;
      }
  
  }
  </code></pre>
  
  <p>And this is how the datetime field is added to the form builder:</p>
  
  <pre><code>$formBuilder-&gt;add('created', 'datetime', array('read_only' =&gt; true));
  </code></pre>
  
  <p>However, symfony still tries to set the unchanged value back to my form type. Since it's read-only I only implemented a get method but not set method. That's why I get this error message:</p>
  
  <pre><code>InvalidPropertyException: Neither element "created" nor method "setCreated()" exists in class "Cinergy\ShopBundle\Tests\Functional\TestBundle\Entity\RecurringProduct"
  
      in /Users/ernst/Source/php/cinergy/shop/vendor/symfony/symfony/src/Symfony/Component/Form/Util/PropertyPath.php line 552
      at PropertyPath-&gt;writeProperty(object(RecurringProduct), 'created', null, false, null) in /Users/ernst/Source/php/cinergy/shop/vendor/symfony/symfony/src/Symfony/Component/Form/Util/PropertyPath.php line 318
      at PropertyPath-&gt;setValue(object(RecurringProduct), null) in /Users/ernst/Source/php/cinergy/shop/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php line 74
      at PropertyPathMapper-&gt;mapFormsToData(array('created' =&gt; object(Form), 'duration' =&gt; object(Form), 'id' =&gt; object(Form), 'name' =&gt; object(Form), 'price' =&gt; object(Form), 'sku' =&gt; object(Form), 'updated' =&gt; object(Form), '__entity' =&gt; object(Form), '__id' =&gt; object(Form)), object(RecurringProduct)) in /Users/ernst/Source/php/cinergy/shop/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 569
      at Form-&gt;bind(object(Request)) in /Users/ernst/Source/php/cinergy/shop/src/Cinergy/DaylightBundle/Controller/BrowserController.php line 123
      at BrowserController-&gt;updateAction(object(Request))
      at call_user_func_array(array(object(BrowserController), 'updateAction'), array(object(Request))) in /Users/ernst/Source/php/cinergy/shop/src/Cinergy/CommonBundle/EventListener/TransactionWrapper.php line 34
      at TransactionWrapper-&gt;wrappedExecution(object(Request))
      at call_user_func_array(array(object(TransactionWrapper), 'wrappedExecution'), array(object(Request))) in /Users/ernst/Source/php/cinergy/shop/app/bootstrap.php.cache line 1426
      at HttpKernel-&gt;handleRaw(object(Request), '1') in /Users/ernst/Source/php/cinergy/shop/app/bootstrap.php.cache line 1390
      at HttpKernel-&gt;handle(object(Request), '1', true) in /Users/ernst/Source/php/cinergy/shop/app/bootstrap.php.cache line 1566
      at HttpKernel-&gt;handle(object(Request), '1', true) in /Users/ernst/Source/php/cinergy/shop/app/bootstrap.php.cache line 617
      at Kernel-&gt;handle(object(Request)) in /Users/ernst/Source/php/cinergy/shop/web/app_dev.php line 28
  </code></pre>
  
  <p>Since this is part of my business logic I don't want to implement a setCreate method. It's also woth mentioning, that the very same thing works fine for text fields. </p>
  
  <p>Any ideas about how I can stop symfony from setting the value if the <code>read_only</code> option is set?</p>