title: How to structure Symfony to check for `onChange` dropdown fields?
body: <p>In my example, I have four entities that I want to use for a blog platform: <kbd>Owner</kbd> <kbd>Post</kbd> <kbd>User</kbd> <kbd>Location</kbd></p>
  
  <ul>
  <li>An <kbd>Owner</kbd> can have multiple <kbd>Posts</kbd></li>
  <li>A <kbd>Post</kbd> can have multiple <kbd>Users</kbd> and <kbd>Locations</kbd></li>
  </ul>
  
  <p>I am trying to create an admin form where I can select the <kbd>Owner</kbd> from a dropdown menu, that will refresh the form <code>onChange</code> to populate the dropdown menu of <kbd>Posts</kbd>. </p>
  
  <p>When a <kbd>Post</kbd> is then selected, the form is again refreshed with form fields <kbd>Users</kbd> and <kbd>Locations</kbd> associated to that post. I can then either:</p>
  
  <ol>
  <li>Update the existing entities with more information (eg User's date of birth or Location's GPS coordinates)</li>
  <li>Create a new instance of either entity to attach to the <kbd>Post</kbd></li>
  </ol>
  
  <p>I've not included the <kbd>Location</kbd> entity and not included the namespaces/include statements as they would detract from my main question of how such an admin page should be coded in the controller/Formtypes (my attempts are as follows):</p>
  
  <h1> Controller:</h1>
  
  <pre><code>/**
  * @Route("/adminposts", name="admin_posts")
  */
  public function updatePostsAction(Request $request)
  {
    $user = new User();
    $form = $this-&gt;createForm(new UserType(), $user);
    $form-&gt;handleRequest($request);
  
    if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($owner);
          $em-&gt;persist($post);
          $em-&gt;persist($user);
          $em-&gt;persist($location);
          $em-&gt;flush();
          return $this-&gt;redirectToRoute('homepage');
    }
    return $this-&gt;render('AppBundle:Default:adminupdate.post.html.twig', array(
          'form' =&gt; $form-&gt;createView(),
    ));
  }
  </code></pre>
  
  <h1>User Formtype: </h1>
  
  <pre><code>class UserType extends AbstractType
  {
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
          $builder
               -&gt;add('owner','entity',array(
                    'class'=&gt;'AppBundle:Owner',
                    'choice_label'=&gt;'username',
                    'query_builder'=&gt;function(EntityRepository $er) {
                          return $er-&gt;createQueryBuilder('d')
                               -&gt;orderBy('d.username','ASC');
                    }))
  
               -&gt;add('post','entity',array(
                    'class'=&gt;'AppBundle:Post',
                    'choice_label'=&gt;'posttext',
                    'query_builder'=&gt;function(EntityRepository $er) {
                          return $er-&gt;createQueryBuilder('d')
                               -&gt;orderBy('d.postdate','ASC');
                    }))
  
               -&gt;add('Firstname')
               -&gt;add('Surname')
               -&gt;add('DOB')
               -&gt;getForm();
    }
  
    public function configureOptions(OptionsResolver $resolver)
    {
          $resolver-&gt;setDefaults(array(
               'data_class' =&gt; 'AppBundle\Entity\Users',
          ));
    }
  
    public function getName()
    {
          return 'user';
    }
  }
  </code></pre>