title: Symonfy form: display input according to value of other field (Twig)
body: <h2>Problem</h2>
  
  <p>I have a form in my Symfony 2(.1.8) application for creating an entry in a table called <code>media</code>. I build the form with the buildForm function in my media form class.<br />
  Amongst other fields the <code>media</code> table has these 3 fields: <code>url</code>, <code>mediatype</code> and <code>file</code>.</p>
  
  <p>The <code>mediatype</code> is a relationship with a <code>mediatype</code> table and I render it as a drop down with the two values: <code>VIDEO</code> and <code>IMAGE</code>. </p>
  
  <p>What I want to do now:
  When the user selects <code>VIDEO</code> in the dropdown the <code>url</code> form_row should be visible. When he selects <code>IMAGE</code> in the dropdown, the <code>file</code> form_row should be visible. When the user hasn't selected anything yet, neither <code>url</code> or <code>file</code> should be visible. <br /><br />
  I tried this with this piece of code (but offcourse it's not working because the form.vars isn't dynamic I guess?):</p>
  
  <pre><code> {% if form.vars.value.mediatype == "video" %}
       {{ form_row(form.url, { 'attr': {'class': 'form_url'} }) }}
   {% elseif form.vars.value.mediatype == "image" %}
       {{ form_row(form.file, { 'attr': {'class': 'form_file'} }) }}
   {% endif %}
  </code></pre>
  
  <p><br /></p>
  
  <h2>Question</h2>
  
  <p>Is there a good way to do this using Twig and/or the Symfony framework? I was thinking of doing it with Javascript, but I first want to know for sure if it isn't possible with Twig/Symfony itself?</p>
  
  <p>Thanks in advance!</p>