Symfony2 displaying countries states and cities based on the input

I am trying to create a registration form with the Symfony2 formbuilder. This is my first time and I have a few problems. How can I display all the cities and states based on the country input? For exampel if I select UK I want to get all of the states of UK, and after the states all of the cities in that state… How is that achieved? I only found the country option in the form documentation, which displays all of the countries… But what to do with the states and cities?

This is the form:

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')

               return $this->render('MpShopBundle:Frontend:registration.html.twig',  array(


What can I do>?

Source: forms

1 Comment

  1. Digin Dominic

    look for the translation_domain option which allow you to set custom label depending of language

    array('label' => 'Comment.author_name', 'translation_domain' => 'myDomain


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.