title: Symfony 3.4 Ajax in Form event
body: <p>In my project, the form allow user select a Map in a SelectBox. When Map Selectbox change, the options in GroupLayer Selectbox also change depend on which Map is selected. I see exactly Symfony document for my case in: <a href="https://symfony.com/doc/current/form/dynamic_form_modification.html#dynamic-generation-for-submitted-forms" rel="nofollow noreferrer">How to Dynamically Modify Forms Using Form Events</a>
  Howerver, in example code:</p>
  
  <pre><code>$formModifier = function (FormInterface $form, Sport $sport = null) {
          $positions = null === $sport ? array() : $sport-&gt;getAvailablePositions();
  
          $form-&gt;add('position', EntityType::class, array(
              'class' =&gt; 'App\Entity\Position',
              'placeholder' =&gt; '',
              'choices' =&gt; $positions,
          ));
      };
  </code></pre>
  
  <p>I don't know where the <code>getAvailablePositions()</code> function should be and what is the returning of this function?. I think this function will be placed in <code>Sport</code> Entity. Is that right, in <code>Sport</code> Entity, could I query the <code>Position</code> Entity with Doctrine ORM queryBuilder? </p>