<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RegisterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$editProdil = $options['edit_profil'];
$builder
->add('firstName', null, [
'label' => 'Prénom',
'attr' => [
'placeholder' => 'Prénom',
'class' => 'input'
]
])
->add('lastName', null, [
'label' => 'Nom',
'attr' => [
'placeholder' => 'Nom',
'class' => 'input'
]
])
->add('email', null, [
'label' => 'Email',
'attr' => [
'placeholder' => 'Email',
'class' => 'input'
]
])
->add('isAcceptPromos', null, [
'label' => 'j’accepte de recevoir des promotions',
'attr' => [
'placeholder' => 'j’accepte de recevoir des promotions',
'class' => 'input'
]
])
;
if(!$editProdil)
$builder->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Mot de passe', 'attr' => ['placeholder' => 'Mot de passe']),
'second_options' => array('label' => 'Confirmer mot de passe','attr' => ['placeholder' => 'Confirmer mot de passe']),
));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
'edit_profil' => false
]);
}
}