Showing results based of previous form field

I’m trying to make a form I’m working on easier to use. Currently after you select a user you then have to select their website from a list of thousands. What I want to do is narrow the site selection down to only those linked to that particular user. I’m not sure how to do this or if it’s possible at all.

The form is built using Silex (a form of Symfony 2) and looks like this:

public function buildForm(FormBuilderInterface $builder, array $options)
  {
$sites      = array(-1=>'New site')+UserSiteQuery::create()->choices();

    $builder
      ->add('user_id', 'choice', array(
        'choices' => $users,
        'label'   => 'User',
        'constraints' => new Assert\\NotBlank(),
        'empty_value' => '',
      ))
      ->add('user_site_id', 'choice', array(
        'choices'     => $sites,
        'label'       => 'User site',
        'empty_value' => 'None',
        'empty_data' => '206',
      ));

To $sites array in on another file and looks like this:


class UserSiteQuery extends BaseUserSiteQuery
{
  public function choices()
  {
    $choices = array();
    $records = $this->useUserQuery()->orderByName()->endUse()->orderByName()->find();
    foreach($records as $row) {
      $choices[ $row->getUser()->__toString() ][ $row->getId() ] = $row->getName();
    }

    return $choices;
  }
}

Essentially what I’m trying to do is something like, get user id from the Users drop down (the first field in the form), then use that id to show only relevant sites.

Thanks in advance for any help.