Ejemplo n.º 1
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['password']) {
         $builder->add('password', 'repeated', array('first_name' => 'password', 'second_name' => 'confirm', 'type' => 'password', 'mapped' => false))->add('submit', 'submit');
     } else {
         $builder->add('username', 'text')->add('fullName', 'text', array('required' => false));
         if ($options['mode'] == 'new') {
             $builder->add('password', 'repeated', array('first_name' => 'password', 'second_name' => 'confirm', 'type' => 'password'));
         }
         $builder->add('role', 'choice', array('choices' => User::getAvailableRoles()))->add('email', 'email')->add('birthDate', 'text')->add('gender', 'choice', array('choices' => array('1' => 'Male', '0' => 'Female')))->add('state', 'text', array('attr' => array('placeholder' => 'Nuevo León')))->add('city', 'text', array('attr' => array('placeholder' => 'Monterrey')))->add('work', 'text', array('label' => 'Professional Experience'))->add('education', 'choice', array('choices' => User::getAvailableEducations()))->add('isActive', 'choice', array('choices' => array('1' => 'Active', '0' => 'Inactive')))->add('submit', 'submit');
     }
 }
Ejemplo n.º 2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['password']) {
         $builder->add('password', 'repeated', array('first_name' => 'password', 'second_name' => 'confirm', 'type' => 'password', 'mapped' => false))->add('submit', 'submit');
     } else {
         $builder->add('username', 'text', array('label' => 'Nombre de usuario (username)'))->add('fullName', 'text', array('label' => 'Nombre completo'))->add('email', 'email');
         if ($options['mode'] == 'new') {
             $builder->add('password', 'repeated', array('first_name' => 'password', 'second_name' => 'confirm', 'type' => 'password', 'first_options' => array('label' => 'Contraseña'), 'second_options' => array('label' => 'Confirma tu contraseña')));
         }
         if ($options['role'] == 'ROLE_ACTIVE') {
             $builder->add('birthDate', 'text', array('label' => 'Fecha de nacimiento'))->add('gender', 'choice', array('label' => 'Sexo', 'choices' => array('1' => 'Masculino', '0' => 'Femenino')))->add('state', 'text', array('label' => 'Estado', 'attr' => array('placeholder' => 'Nuevo León')))->add('city', 'text', array('label' => 'Ciudad', 'attr' => array('placeholder' => 'Monterrey')))->add('work', 'text', array('label' => 'Experiencia profesional', 'attr' => array('placeholder' => 'Director de ventas en X')))->add('education', 'choice', array('choices' => User::getAvailableEducations(), 'label' => 'Nivel de estudios'));
         }
         $builder->add('Crear usuario', 'submit');
     }
 }