src/Form/Type/UserRegistrationType.php line 24
- <?php
- namespace App\Form\Type;
- use Doctrine\ORM\EntityManagerInterface;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
- use FOS\UserBundle\Form\Type\RegistrationFormType;
- use Symfony\Component\Validator\Constraints\IsTrue;
- use App\Entity\User;
- use App\Entity\Pais;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Component\Form\Extension\Core\Type\PasswordType;
- use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use Symfony\Component\Form\Extension\Core\Type\DateType;
- use Symfony\Component\Form\Extension\Core\Type\FileType;
- use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use Doctrine\ORM\EntityRepository;
- class UserRegistrationType extends AbstractType
- {
- // protected $locale;
- // protected $request;
- //
- // public function __construct($locale)
- // {
- // $this->locale=$locale;
- // }
- public function getParent()
- {
- return RegistrationFormType::class;
- }
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- parent::buildForm($builder, $options);
- $locale = $options['locale'];
- $em = $options['em'];
- // $fullName = $options['fullName'];
- // $email = $options['email'];
- // $orderCode = $options['orderCode'];
- $builder
- ->add('name', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.card.nameLabel'),
- 'attr' => array(
- 'placeholder' => 'Nombre Completo',
- 'required' => true,
- )
- )
- )
- ->add('idCard', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.card.nameLabel'),
- 'attr' => array(
- 'placeholder' => 'Numero del cocumento',
- 'required' => true,
- )
- )
- )
- ->add('email', TextType::class, array(
- 'label' => $options['sm']->getValue('page.business.emailForm'),
- 'data' => null/*$email*/,
- 'attr' => array(
- 'placeholder' => 'E-mail',
- )
- )
- )
- ->add('telefono', TextType::class, array(
- 'label' => $options['sm']->getValue('user.phone'),
- 'data' => null/*$email*/,
- 'attr' => array(
- 'placeholder' => 'Teléfono',
- )
- )
- )
- ->add('pais',EntityType::class, array(
- 'class' => 'App\Entity\Pais',
- 'label' => $options['sm']->getValue('profile.address.country'),
- 'placeholder' => 'Selecciona un país',
- 'choice_attr' => function ($pais) {
- return ['data-iso' => $pais->getIso3()];
- },
- ))
- ->add('direccion1', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.address.label1'),
- 'attr' => array(
- 'placeholder' => 'Direccion completa',
- 'maxlength' => 50
- )
- )
- )
- ->add('ciudad', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.address.city'),
- 'attr' => array(
- 'placeholder' => 'Población',
- )
- )
- )
- ->add('county', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.address.region'),
- 'attr' => array(
- 'placeholder' => 'Provincia',
- )
- )
- )
- ->add('cp', TextType::class, array(
- 'label' => $options['sm']->getValue('profile.address.pc'),
- 'attr' => array(
- 'placeholder' => 'Código postal',
- )
- )
- )
- ->add('urlImagen', FileType::class, array(
- // 'label' => false,
- 'label' => $options['sm']->getValue('profile.card.ImgLabel'),
- 'data_class' => 'Symfony\Component\HttpFoundation\File\File',
- "attr" =>array("class" => "form-control"),
- 'validation_groups' => ['create'],
- 'required' => false,
- ))
- ->add('urlImagenCheckbox', CheckboxType::class, array(
- 'label' => $options['sm']->getValue('profile.card.parte_trasera'),
- 'required' => false,
- 'mapped' => false,
- ))
- ->add('urlImagen2', FileType::class, array(
- 'label' => $options['sm']->getValue('profile.card.traseraa'),
- 'required' => false,
- 'data_class' => 'Symfony\Component\HttpFoundation\File\File',
- "attr" =>array('class' => "form-control-trasero hidden",
- 'placeholder' => "Parte trasera"
- ),
- 'validation_groups' => ['create'],
- ))
- ->add('privacy_policy_consent', CheckboxType::class, array(
- 'label' => $options['sm']->getValue('user.register.terms'),
- 'required' => true,
- 'mapped' => false,
- 'constraints' => array(new IsTrue()),
- )
- )
- ->add('plainPassword', RepeatedType::class, array(
- 'type' => PasswordType::class,
- 'options' => array('translation_domain' => 'FOSUserBundle'),
- 'first_options' => array(
- 'label' => 'form.password',
- 'attr' =>array(
- 'placeholder' => 'Contraseña'
- )
- ),
- 'second_options' => array(
- 'label' => 'form.password_confirmation',
- 'attr' =>array(
- 'placeholder' => 'Repita la contraseña*'
- )
- )
- )
- )
- ->add('idCard', HiddenType::class, array(
- 'label' => 'Numero de documento',
- 'attr' => array(
- 'placeholder' => 'Numero de documento',
- 'required' => true,
- )
- )
- )
- ->add('tipoDocumento',EntityType::class, array(
- 'class' => 'App\Entity\TipoDocumento',
- 'choice_label' => function ($tipoDocumento) {
- return $tipoDocumento->getNombre();
- },
- 'label' => $options['sm']->getValue('profile.card.idTypeLabel'),
- 'attr' => array(
- 'placeholder' => 'Selecciona documento',
- 'required' => false,
- )
- ))
- ->add('fechaCaducidad', DateType::class, array(
- 'widget' => 'single_text',
- 'html5' => true,
- // 'format' => 'dd-MM-yyyy',
- 'label' => $options['sm']->getValue('user.expiredDate'),
- 'attr' => array(
- 'placeholder' => 'Fecha de caducidad',
- 'class'=>'form-control input-inline datepicker',
- 'data-provide' => 'datepicker',
- 'data-date-format' => 'dd-mm-yyyy',
- 'required' => false,
- )
- ))
- ->add('fechaNacimiento', DateType::class, array(
- 'widget' => 'single_text',
- 'html5' => true,
- // 'format' => 'dd-MM-yyyy',
- 'label' => $options['sm']->getValue('profile.card.bornLabel'),
- 'attr' => array(
- 'placeholder' => 'Fecha de nacimiento',
- 'class'=>'form-control input-inline datepicker',
- 'data-provide' => 'datepicker',
- 'data-date-format' => 'dd-mm-yyyy',
- 'required' => false,
- )
- ))
- // ->add('newsletterSub', 'checkbox',array(
- // 'label' => 'Quiero suscribirme a las noticias',
- // 'mapped'=> false,
- // 'required' =>false,
- // 'attr' => array('checked' => 'checked'),
- // )
- //
- // )
- ->remove('username') //Remove it from the form because we use the e-mail as username
- ;
- }
- public function configureOptions(OptionsResolver $resolver)
- {
- // parent::setDefaultOptions($resolver);
- $resolver->setDefaults( array(
- 'data_class' => 'App\Entity\User',
- 'orderCode' => null,
- 'email' => '',
- 'fullName' => '',
- 'locale' => null,
- 'em' => null,
- 'sm' => null
- ));
- }
- public function getName()
- {
- return 'dinamic_user_registration';
- }
- }