Form/Type/ChoicesListType.php
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $locales = $this->defaultLocales;
        
        $builder->add('name', 'translatable_string')
            ->add('active', 'checkbox', array(
                'required' => false
            ))
            ->add('slug', 'hidden', array(
                
            ))
            ->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) use ($locales){
                $form = $event->getForm();
                $data = $event->getData();

                $formData = $form->getData();
                
                if (NULL === $formData['slug']) {
                    $slug = $form['name'][$locales[0]]->getData();
                    $slug = strtolower($slug);
                    $slug = preg_replace('/[^a-zA-Z0-9 -]/','', $slug); // only take alphanumerical characters, but keep the spaces and dashes too...
                    $slug = str_replace(' ','-', $slug); // replace spaces by dashes
                    
                    $data['slug'] = $slug;
                    $event->setData($data);
                } else {
                    $data['slug'] = $formData['slug'];
                    $event->setData($data);
                }
            })
        ;
    }
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $locales = $this->defaultLocales;
        
        $builder->add('name', 'translatable_string')
            ->add('active', 'checkbox', array(
                'required' => false
            ))
            ->add('slug', 'hidden', array(
                
            ))
            ->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) use ($locales){
                $form = $event->getForm();
                $data = $event->getData();

                $formData = $form->getData();
                
                if (NULL === $formData['slug']) {
                    $slug = $form['name'][$locales[0]]->getData();
                    $slug = strtolower($slug);
                    $slug = preg_replace('/[^a-zA-Z0-9 -]/','', $slug); // only take alphanumerical characters, but keep the spaces and dashes too...
                    $slug = str_replace(' ','-', $slug); // replace spaces by dashes
                    
                    $data['slug'] = $slug;
                    $event->setData($data);
                } else {
                    $data['slug'] = $formData['slug'];
                    $event->setData($data);
                }
            })
        ;
    }
/* (non-PHPdoc)
@see \Symfony\Component\Form\AbstractType::buildForm()