src/Aviatur/CustomerBundle/Form/Type/RegistrationFormType.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSUserBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Aviatur\CustomerBundle\Form\Type;
  11. use Aviatur\FormBundle\Form\DatePickerType;
  12. use Symfony\Component\Form\AbstractType;
  13. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  14. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. /* Clases nuevas */
  18. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  19. class RegistrationFormType extends AbstractType
  20. {
  21.     private $class;
  22.     /**
  23.      * @var array
  24.      */
  25.     protected $mergeOptions;
  26.     /**
  27.      * @param string $class        The User class name
  28.      * @param array  $mergeOptions Add options to elements
  29.      */
  30.     public function __construct($class, array $mergeOptions = [])
  31.     {
  32.         $this->class $class;
  33.         $this->mergeOptions $mergeOptions;
  34.     }
  35.     public function buildForm(FormBuilderInterface $builder, array $options)
  36.     {
  37.         $builder
  38.             ->add('username'nullarray_merge([
  39.                 //'label' => 'form.username',
  40.                 'label' => 'Nombre de Usuario',
  41.                 'translation_domain' => 'FOSUserBundle',
  42.                 'attr' => ['class' => 'text-input''placeholder' => 'Nombre de Usuario'],
  43.             ], $this->mergeOptions))
  44.             ->add('email', \Symfony\Component\Form\Extension\Core\Type\EmailType::class, array_merge([
  45.                 //'label' => 'form.email',
  46.                 'label' => 'Email',
  47.                 'translation_domain' => 'FOSUserBundle',
  48.                 'attr' => ['class' => 'text-input''placeholder' => 'Email'],
  49.             ], $this->mergeOptions))
  50.             ->add('documentType'nullarray_merge([
  51.                 'required' => true,
  52.                 //'label' => 'form.doctype',
  53.                 'label' => 'Tipo de Documento',
  54.                 'translation_domain' => 'FOSUserBundle',
  55.                 'attr' => ['class' => 'text-input js-documentType'],
  56.                 'placeholder' => 'Selecciona un tipo de documento',
  57.             ], $this->mergeOptions))
  58.             ->add('documentNumber'nullarray_merge([
  59.                 'required' => true,
  60.                 //'label' => 'form.docnumber',
  61.                 'label' => 'Número de Documento',
  62.                 'translation_domain' => 'FOSUserBundle',
  63.                 'attr' => ['class' => 'text-input''placeholder' => 'Número de Documento''maxlength' => 15],
  64.             ], $this->mergeOptions))
  65.             ->add('birthdate'DatePickerType::class, [
  66.                 'placeholder' => ['year' => 'Año''month' => 'Mes''day' => 'Día'],
  67.                 'label' => 'Fecha de Nacimiento''attr' => ['class' => 'text-input'],
  68.                 'attr' => ['class' => 'text-input'],
  69.             ])
  70.             ->add('firstname'nullarray_merge([
  71.                 'required' => true,
  72.                 //'label' => 'form.firstname',
  73.                 'label' => 'Nombres',
  74.                 'translation_domain' => 'FOSUserBundle',
  75.                 'attr' => ['class' => 'text-input''placeholder' => 'Nombres'],
  76.             ], $this->mergeOptions))
  77.             ->add('lastname'nullarray_merge([
  78.                 'required' => true,
  79.                 //'label' => 'form.lastname',
  80.                 'label' => 'Apellidos',
  81.                 'translation_domain' => 'FOSUserBundle',
  82.                 'attr' => ['class' => 'text-input''placeholder' => 'Apellidos'],
  83.             ], $this->mergeOptions))
  84.             ->add('genderAviatur'nullarray_merge([
  85.                 'required' => true,
  86.                 //'label' => 'form.gender',
  87.                 'label' => 'Género',
  88.                 'translation_domain' => 'FOSUserBundle',
  89.                 'attr' => ['class' => 'text-input'],
  90.             ], $this->mergeOptions))
  91.             ->add('address'nullarray_merge([
  92.                 'required' => true,
  93.                 //'label' => 'form.address',
  94.                 'label' => 'Dirección',
  95.                 'translation_domain' => 'FOSUserBundle',
  96.                 'attr' => ['class' => 'text-input''placeholder' => 'Dirección'],
  97.             ], $this->mergeOptions))
  98.             ->add('phone'nullarray_merge([
  99.                 'required' => true,
  100.                 //'label' => 'form.phone',
  101.                 'label' => 'Teléfono',
  102.                 'translation_domain' => 'FOSUserBundle',
  103.                 'attr' => ['class' => 'text-input''placeholder' => 'Teléfono'],
  104.             ], $this->mergeOptions))
  105.             ->add('cellphone'nullarray_merge([
  106.                 'required' => true,
  107.                 //'label' => 'form.cellphone',
  108.                 'label' => 'Celular',
  109.                 'translation_domain' => 'FOSUserBundle',
  110.                 'attr' => ['class' => 'text-input''placeholder' => 'Celular'],
  111.             ], $this->mergeOptions))
  112.             ->add('plainPassword', \Symfony\Component\Form\Extension\Core\Type\RepeatedType::class, array_merge([
  113.                 'type' => PasswordType::class,
  114.                 'options' => ['translation_domain' => 'FOSUserBundle'],
  115.                 'first_options' => array_merge([
  116.                     //'label' => 'form.password',
  117.                     'label' => 'Contraseña',
  118.                     'attr' => ['class' => 'text-input''placeholder' => 'Contraseña'],
  119.                 ], $this->mergeOptions),
  120.                 'second_options' => array_merge([
  121.                     //'label' => 'form.password_confirmation',
  122.                     'label' => 'Repita la Contraseña',
  123.                     'attr' => ['class' => 'text-input''placeholder' => 'Repita la Contraseña'],
  124.                 ], $this->mergeOptions),
  125.                 'invalid_message' => 'fos_user.password.mismatch',
  126.             ], $this->mergeOptions))
  127.             ->add('acceptconditions'CheckboxType::class, array_merge([
  128.                 'required' => true,
  129.                 //'label' => 'form.conditions',
  130.                 'label' => 'Acepto las Políticas de uso de datos',
  131.                 'translation_domain' => 'FOSUserBundle',
  132.             ], $this->mergeOptions))
  133.         ;
  134.     }
  135.     public function configureOptions(OptionsResolver $resolver)
  136.     {
  137.         $resolver->setDefaults([
  138.             'data_class' => $this->class,
  139.             'intention' => 'registration',
  140.         ]);
  141.     }
  142.     public function getParent()
  143.     {
  144.         return \FOS\UserBundle\Form\Type\RegistrationFormType::class;
  145.     }
  146.     public function getBlockPrefix()
  147.     {
  148.         return 'aviatur_user_registration';
  149.     }
  150. }