<?php
/**
* Created by PhpStorm.
* User: bertrand
* Date: 02/04/2019
* Time: 20:26
*/
namespace App\Form\Type;
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\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->remove('username')
->add('firstname', TextType::class, [
'label' => 'Prénom'
])
->add('lastname', TextType::class, [
'label' => 'Nom'
])
->add('phoneNumber', TelType::class, [
'label' => 'Téléphone',
'attr' => [
'class' => 'cleave-phone-number'
]
])
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'options' => array('translation_domain' => 'FOSUserBundle'),
'first_options' => array('label' => 'form.password'),
'second_options' => array('label' => 'Confirmer le mot de passe'),
'invalid_message' => 'fos_user.password.mismatch',
'constraints' => [
new NotBlank(),
new Length(['min' => 8]),
],
)
)
->add('administrator', FreelancerFormType::class)
->add('cgv', CheckboxType::class, [
'label' => false,
'required' => true,
'mapped' => false,
])
->add('submit', SubmitType::class, [
'label' => 'Créer mon compte',
'attr' => [
'class' => 'btn btn-primary transition-3d-hover w-100',
]
]);
}
public function getParent()
{
return 'FOS\UserBundle\Form\Type\RegistrationFormType';
}
public function getBlockPrefix()
{
return 'app_user_registration';
}
}