Created
September 8, 2011 12:41
-
-
Save anonymous/1203305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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