Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2011 12:41
Show Gist options
  • Save anonymous/1203305 to your computer and use it in GitHub Desktop.
Save anonymous/1203305 to your computer and use it in GitHub Desktop.
/* Controller */
public function registerAction()
{
$entity = new User();
$entity->setSex('m');
$entity->setPro(false);
$form = $this->createForm(new RegisterUserType(), $entity);
return array(
'entity' => $entity,
'form' => $form->createView()
);
}
/* Form */
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class RegisterUserType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('firstname', null, array('label' => 'Prénom'))
->add('lastname', null, array('label' => 'Nom'))
->add('password', 'repeated', array('type' => 'password', 'first_name' => 'Mot de passe', 'second_name' => 'Confirmer votre mot de passe', 'required' => true))
->add('sex', 'choice', array('label' => 'Sexe', 'expanded' => true, 'multiple' => false, 'choices' => array('m' => '#Homme', 'f' => '#Femme')))
->add('email', 'email', array('label' => 'Adresse email'))
->add('username', null, array('label' => 'Choissisez pseudo'));
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment