title: How to disable a field in edit view using Symfony 2 FormBuilder
body: <p>I created a form with Symfony2 FormBuilder and I want to disabled one of the fields in the edit view. I'm actually hiding it with a wrapper (<code>display:none</code>) but I was wondering if there's a better way to do this. My code looks like the following:</p>
  
  <p><strong>EntityType</strong></p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options) {
      $builder-&gt;add('fieldToDisabledInEditView');
      // ...
  </code></pre>
  
  <p><strong>EntityController</strong></p>
  
  <pre><code>public function newAction() {
      $entity = new Entity;
      $form = $this-&gt;createForm(new EntityType, $entity);
      // ...
  }
  public function editAction() {
      $entity = new Entity;
      $form = $this-&gt;createForm(new EntityType, $entity);
      // ...
  }
  </code></pre>
  
  <p><strong>New (twig) Template</strong></p>
  
  <pre><code>&lt;form&gt;
      {{ form_row(form.fieldToDisabledInEditView) }}
      {# ... #}
  </code></pre>
  
  <p><strong>Edit (twig) Template</strong></p>
  
  <pre><code>&lt;form&gt;
      &lt;span class="theValueOfTheHiddenField"&gt;{{ entity.fieldToDisabledInEditView }}&lt;/span&gt;
      &lt;div style="display:none"&gt;
          {{ form_row(form.fieldToDisabledInEditView) }}
      &lt;/div&gt;
      {# ... #}
  </code></pre>