Symfony2根据输入显示国家、州和城市


Symfony2 displaying countries states and cities based on the input

我试图用Symfony2 formbuilder创建一个注册表单。这是我第一次来,我遇到了一些问题。如何根据输入的国家显示所有的城市和州?例如,如果我选择UK,我想要得到英国的所有州,在州之后是那个州的所有城市……这是如何实现的呢?我只在表单文档中找到了国家选项,它显示了所有国家……但是各州和各市该怎么办呢?

格式是:

public function registerAction()
    {   
            $em = $this->getDoctrine()->getManager();
            $products = $em->getRepository('MpShopBundle:Product')->findAll();
            $form = $this->createFormBuilder()
                ->add('title', 'choice', array(
                'choices' => array('-' => '-', 'mr' => 'Mr.', 'mrs' => 'Mrs.', 'mss' => 'Miss.')))
                ->add('firstname', 'text')
                ->add('lastname', 'text')
                ->add('Email', 'email')
                ->add('Password', 'password')
                ->add('DateOfBirth', 'date')
                ->add('Company', 'text')
                ->add('Adress', 'text')
                ->add('Country', 'country')
                ->add('State', 'locale')    
                ->add('City', 'text')
                ->add('ZipPostalCode', 'text')
                ->add('AdditionalInformation', 'textarea')
                ->add('HomePhone', 'number')
                ->add('MobilePhone', 'number')
                ->getForm()
                ;
               return $this->render('MpShopBundle:Frontend:registration.html.twig',  array(
               'products'=>$products,
               'form'=>$form->createView(),    
               ));
    } 

我能做什么>?

http://symfony.com/doc/current/reference/forms/types/form.html

查找translation_domain选项,该选项允许您根据语言设置自定义标签

$builder->add(
'author_name',
'text',
array('label' => 'Comment.author_name', 'translation_domain' => 'myDomain