-
-
Save MrPOC/a4af94cc5e577a1244dac59de5ea3506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: djpoc | |
* Date: 07-07-18 | |
* Time: 11:12 | |
*/ | |
namespace App\Form; | |
use App\Entity\User; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | |
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |
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\TextType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\OptionsResolver\OptionsResolver; | |
class UserType extends AbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder | |
->add('firstName', TextType::class, array( | |
'label' => 'Prénom', | |
'attr' => array('class' => 'pds-input') | |
)) | |
->add('lastName', TextType::class, array( | |
'label' => 'Nom de famille', | |
'attr' => array('class' => 'pds-input') | |
)) | |
->add('email', EmailAddressType::class, array( | |
'label' => 'Adresse email', | |
)) | |
->add('password', RepeatedType::class, array( | |
'type' => PasswordType::class, | |
'invalid_message' => 'Les mots de passes doivent correspondre.', | |
'options' => array('attr' => array('class' => 'pds-input')), | |
'required' => true, | |
'first_options' => array('label' => 'Mot de passe'), | |
'second_options' => array('label' => 'Confirmation du mot de passe'), | |
)) | |
->add('phoneNumbers', CollectionType::class, array( | |
'entry_type' => PhoneNumberType::class, | |
'label' => 'Numéro(s) de téléphone', | |
'label_attr' => array('class' => 'label-section-title'), | |
'attr' => array('class' => 'section user-phonenumbers-collectionholder'), | |
'entry_options' => array('label' => false), | |
'allow_add' => true, | |
'by_reference' => false, | |
'allow_delete' => true | |
)) | |
->add('address', AddressType::class, array( | |
'label' => 'Adresse postale', | |
'label_attr' => array('class' => 'label-section-title'), | |
'attr' => array('class' => 'section'), | |
)) | |
->add('additionalEmails', CollectionType::class, array( | |
'entry_type' => EmailAddressType::class, | |
'label' => 'Adresses email supplémentaires', | |
'label_attr' => array('class' => 'label-section-title'), | |
'attr' => array('class' => 'section additional-emails-container'), | |
'entry_options' => array('label' => 'Adresse email'), | |
'allow_add' => true, | |
'by_reference' => false, | |
'allow_delete' => true | |
)) | |
->add('isSelfManagedMember', CheckboxType::class, array( | |
'label' => 'Faites-vous parti du staff ?', | |
'label_attr' => array('class' => 'question-label'), | |
'attr' => array('class' => 'question-case'), | |
'required' => false | |
)) | |
->add('submit', SubmitType::class, array( | |
'label' => "S'inscrire", | |
'attr' => array('class' => 'pds-btn submit-form'), | |
)) | |
; | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
$resolver->setDefaults(array( | |
'data_class' => User::class, | |
'attr' => array('class' => 'top-labels') | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment