<?php
namespace Aqarmap\Bundle\UserBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class QuickRegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (isset($options['onlyLeadData']) && true == $options['onlyLeadData']) {
$builder
->add('fullName', TextType::class)
->add('phoneNumber', TextType::class, ['attr' => ['maxlength' => 15, 'minlength' => 7]])
->add('countryCode', TextType::class, ['mapped' => false, 'attr' => ['maxlength' => 8, 'minlength' => 2]])
;
} elseif (isset($options['onlyEmail']) && true == $options['onlyEmail']) {
$builder
->add('email', EmailType::class)
;
} else {
$builder
->add('fullName', TextType::class)
->add('phoneNumber', TextType::class, ['attr' => ['maxlength' => 15, 'minlength' => 7]])
->add('language', HiddenType::class)
->add('email', EmailType::class)
->add('countryCode', TextType::class, ['mapped' => false, 'attr' => ['maxlength' => 8, 'minlength' => 2]])
;
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => 'Aqarmap\Bundle\UserBundle\Entity\User',
'validation_groups' => ['landing-page', 'quick-registration'],
'csrf_protection' => false,
'onlyLeadData' => false,
'onlyEmail' => false,
]);
}
public function getBlockPrefix(): string
{
return 'register';
}
}