title: Symfony: Hide/Show form element dependent on dropdown selection with database entries
body: <p>I hope my title is proper: I have a dropdown, that comes from a form as an EntityType and the values are from an entity class. Code:</p>
  
  <pre><code>   -&gt;add('type', EntityType::class, array(
        'class' =&gt; 'DocumentBundle:DocumentType',
        'label' =&gt; 'label.type',
        'property' =&gt; 'translationKey',
        'required' =&gt; true,
        'multiple' =&gt; false,
        'expanded' =&gt; false,
        'empty_value' =&gt; 'label.select_type',
        'choice_translation_domain' =&gt; 'Documents'
        ))
    -&gt;add('vka_number', 'text', array(
        'label' =&gt; 'label.vka_number',
        'required' =&gt; false,
        'translation_domain' =&gt; 'Documents'))
  </code></pre>
  
  <p>the second one is a text field (vka_number) that I only want to be shown when a specific value from that dropdown is selected
  in my twig template I render the elements:</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-md-6" id="documentDropdown"&gt;
      {{ form_row(form.type) }}
    &lt;/div&gt;
  
    &lt;div class="col-md-6" id="vka"&gt;
      {{ form_row(form.vka_number) }}
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I was thinking about a javascript function like that:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
      $('#documentDropdown').on('change', function(){
         if (this.value == 'Contract')
         {
           $('#vka').show();
         }
          else {
           $('#vka').hide();
         }
      });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>but it's not working and I think this is because it can't access the values from the dropdown since they are not hard coded but database entries. 
  'Contract' would be the entry (id=1) that "makes" the vka_number text field appear.</p>