<?php
/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Aviatur\CustomerBundle\Form\Type;
use Aviatur\FormBundle\Form\DatePickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/* Clases nuevas */
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
class RegistrationFormType extends AbstractType
{
private $class;
/**
* @var array
*/
protected $mergeOptions;
/**
* @param string $class The User class name
* @param array $mergeOptions Add options to elements
*/
public function __construct($class, array $mergeOptions = [])
{
$this->class = $class;
$this->mergeOptions = $mergeOptions;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username', null, array_merge([
//'label' => 'form.username',
'label' => 'Nombre de Usuario',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Nombre de Usuario'],
], $this->mergeOptions))
->add('email', \Symfony\Component\Form\Extension\Core\Type\EmailType::class, array_merge([
//'label' => 'form.email',
'label' => 'Email',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Email'],
], $this->mergeOptions))
->add('documentType', null, array_merge([
'required' => true,
//'label' => 'form.doctype',
'label' => 'Tipo de Documento',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input js-documentType'],
'placeholder' => 'Selecciona un tipo de documento',
], $this->mergeOptions))
->add('documentNumber', null, array_merge([
'required' => true,
//'label' => 'form.docnumber',
'label' => 'Número de Documento',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Número de Documento', 'maxlength' => 15],
], $this->mergeOptions))
->add('birthdate', DatePickerType::class, [
'placeholder' => ['year' => 'Año', 'month' => 'Mes', 'day' => 'Día'],
'label' => 'Fecha de Nacimiento', 'attr' => ['class' => 'text-input'],
'attr' => ['class' => 'text-input'],
])
->add('firstname', null, array_merge([
'required' => true,
//'label' => 'form.firstname',
'label' => 'Nombres',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Nombres'],
], $this->mergeOptions))
->add('lastname', null, array_merge([
'required' => true,
//'label' => 'form.lastname',
'label' => 'Apellidos',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Apellidos'],
], $this->mergeOptions))
->add('genderAviatur', null, array_merge([
'required' => true,
//'label' => 'form.gender',
'label' => 'Género',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input'],
], $this->mergeOptions))
->add('address', null, array_merge([
'required' => true,
//'label' => 'form.address',
'label' => 'Dirección',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Dirección'],
], $this->mergeOptions))
->add('phone', null, array_merge([
'required' => true,
//'label' => 'form.phone',
'label' => 'Teléfono',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Teléfono'],
], $this->mergeOptions))
->add('cellphone', null, array_merge([
'required' => true,
//'label' => 'form.cellphone',
'label' => 'Celular',
'translation_domain' => 'FOSUserBundle',
'attr' => ['class' => 'text-input', 'placeholder' => 'Celular'],
], $this->mergeOptions))
->add('plainPassword', \Symfony\Component\Form\Extension\Core\Type\RepeatedType::class, array_merge([
'type' => PasswordType::class,
'options' => ['translation_domain' => 'FOSUserBundle'],
'first_options' => array_merge([
//'label' => 'form.password',
'label' => 'Contraseña',
'attr' => ['class' => 'text-input', 'placeholder' => 'Contraseña'],
], $this->mergeOptions),
'second_options' => array_merge([
//'label' => 'form.password_confirmation',
'label' => 'Repita la Contraseña',
'attr' => ['class' => 'text-input', 'placeholder' => 'Repita la Contraseña'],
], $this->mergeOptions),
'invalid_message' => 'fos_user.password.mismatch',
], $this->mergeOptions))
->add('acceptconditions', CheckboxType::class, array_merge([
'required' => true,
//'label' => 'form.conditions',
'label' => 'Acepto las Políticas de uso de datos',
'translation_domain' => 'FOSUserBundle',
], $this->mergeOptions))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->class,
'intention' => 'registration',
]);
}
public function getParent()
{
return \FOS\UserBundle\Form\Type\RegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'aviatur_user_registration';
}
}