title: Symfony2 disabled select
body: <p>I'm trying to implement dynamic forms in Symfony2. The form is simple, first the user selects a broker, and then select an account according to that broker. Therefore, the account is disabled until the broker is selected.</p>
  
  <p>In case of a text input, <code>read_only =&gt; true</code> could be a solution, but select has no attribute readonly. So, I made the select disabled, and then tried to enable the select with jQuery:</p>
  
  <pre><code>$('#form select').prop('disabled', false);
  </code></pre>
  
  <p>The problem is that on the server side, Symfony cannot handle the disabled form field. Its value is simply set to null.</p>
  
  <p>I thought of possible solutions. First of all, I could manually set the field value in the controller, because I tested that the form field value is actually in the request parameter, Symfony just ignores to handle it and map it to the object. I think it would work, however it's not really nice solution.</p>
  
  <p>Secondly, I can disable the select with some client side hacking, or add a hidden input to the form and manually set the value of it with Javascript.</p>
  
  <p>Is there a standard solution here?</p>
  
  <p>My form entity looks like this:</p>
  
  <pre><code>$builder-&gt;add('broker', 'entity', array(
      'class'         =&gt; 'MyBundle:Broker',
      'property'      =&gt; 'name',
      'query_builder' =&gt; function(BrokerRepository $br) {
                             return $br-&gt;getActiveBrokersQuery();
                         },
      'required'      =&gt; true,
      'empty_value'   =&gt; 'Choose a broker',
  ));
  
  $builder-&gt;add('accountType', 'entity', array(
      'class'       =&gt; 'MyBundle:AccountType',
      'empty_value' =&gt; 'Choose a broker first',
      'disabled'    =&gt; true,
  ));
  </code></pre>
  
  <p>If I do not disable the select, everything works fine, Symfony handles the request perfectly.</p>