title: 5 How to set selected option in EntityType optionlist by given id
body: <p>I'm new to Symfony and like to build a form for products with category as a dropdown preselected by the given category id from a get var like /new? category=1.
  So far the categories are rendering correctly into a list by the EntityType how can I preselect the corespondig category? The user still has to be able to select another category so I don't like to just pass it to the product before saving.</p>
  
  <p>Here is what I did so far:</p>
  
  <pre><code>$form = $this-&gt;createFormBuilder($product)
  
          -&gt;add('category', EntityType::class, array(
              'class' =&gt; Category::class,
              'choice_label' =&gt; 'name',
              ))
  
          ....
  
          -&gt;getForm();
  </code></pre>
  
  <p>what I get in the view:</p>
  
  <pre><code>&lt;select id="form_category" name="form[category]"&gt;
      &lt;option value="1"&gt;Electronics&lt;/option&gt;
      &lt;option value="2"&gt;Clothes&lt;/option&gt;
  </code></pre>
  
  <p>What I like to get</p>
  
  <pre><code>&lt;select id="form_category" name="form[category]"&gt;
      &lt;option value="1"&gt;Electronics&lt;/option&gt;
      &lt;option value="2" selected="selected"&gt;Clothes&lt;/option&gt;
  </code></pre>