title: Sonata User Admin - Custom field dependency
body: <p>I have extended the SonataAdmin class for FOSUser and added 2 custom fields (choice type from external data source): <code>Company</code> and <code>Sector</code></p>
  
  <p>I'd like to make <code>Sector</code> dependent on <code>Company</code>, so if the user selects a Company it filters the available Sectors.</p>
  
  <p>I though about using FormEvents for filtering at page load, but I don't even know how to get the <code>Company</code> value of the current form.</p>
  
  <p>Here is a part of my custom <code>SectorType</code></p>
  
  <pre class="lang-php prettyprint-override"><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;addEventListener(FormEvents::PRE_SET_DATA
      , function(FormEvent $event) {
          $data = $event-&gt;getData();
          $form = $event-&gt;getForm();
          // Need to get the company value here if set
      });
  }
  
  public function setDefaultOptions(OptionsResolverInterface $resolver)
  {
      $resolver-&gt;setDefaults(array(
          'choices' =&gt; $this-&gt;getSectors(),
      ));
  }
  
  public function getSectors()
  {
      $sects = array();
      // Need to pass the selected company value to my getList
      // (which gets the list of sector as you can imagine)
      if (($tmp_sects = $this-&gt;ssrs-&gt;getList('Sector'))) {
          foreach ($tmp_sects as $sect) {
              $label = $sect['id'] ? $sect['label'] : '';
              $sects[$sect['id']] = $label;
          }
      }
      return $sects;
  }
  </code></pre>
  
  <p>So the question is:</p>
  
  <p>How to get the selected <code>Company</code> from my custom <code>SectorType</code> ?</p>
  
  <hr>
  
  <p>After that I'll need to be able to refresh the Sector with Ajax, but that will be another question</p>