src/Form/FranchiseType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Franchise;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  8. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints;
  12. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  13. class FranchiseType extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $choices 0;
  18.         $choicestable = array();
  19.         for ($i 0;$i<50;$i++){
  20.             $choicestable[$choices]=$choices;
  21.             $choices += 5000;
  22.         }
  23.         $builder
  24.             ->add('nom')
  25.             ->add('prenom')
  26.             ->add('adresse')
  27.             ->add('cp',null,[
  28.                 'label' => 'Code Postal',
  29.                 'constraints'=>[
  30.                     new Constraints\Callback(function($objectExecutionContextInterface $context){
  31.                         if(preg_match('#[0-9]{5}#i',$object)){
  32.                         }
  33.                         else{
  34.                             if ($object != null)
  35.                             {
  36.                                 $context->buildViolation('Entrée un code postal valide')->addViolation();
  37.                             }
  38.                         }
  39.                     }),
  40.                 ],
  41.             ])
  42.             ->add('ville')
  43.             ->add('departement')
  44.             ->add('pays')
  45.             ->add('mail',EmailType::class,[
  46.                 'label'=>'E-mail',
  47.             ])
  48.             ->add('telephone')
  49.             ->add('secteur',null,[
  50.                 'label'=>"Secteur d'implantation",
  51.             ])
  52.             ->add('apport',IntegerType::class,[
  53.                 'label'=>'Apport Personnel',
  54.                 'attr' => ['min'=>0],
  55.             ])
  56.             ->add('apportcomplement',IntegerType::class,[
  57.                 'label' => 'Apport Complémentaire Possible',
  58.                 'attr' => ['min' => 0],
  59.             ])
  60.             ->add('local',null,[
  61.                 'label' => 'Avez Vous un local ?'
  62.             ])
  63.             ->add('echeance',ChoiceType::class,[
  64.                 'label' =>' Échéance du projet',
  65.                 'choices'=>[
  66.                     '1 Mois - 3 Mois' =>'1 Mois - 3 Mois',
  67.                     '3 Mois - 6 Mois' =>'3 Mois - 6 Mois',
  68.                     '6 Mois et plus' => '6 Mois et plus' ,
  69.                 ]
  70.             ])
  71.             ->add('message')
  72.             ->add('save',SubmitType::class,[
  73.                 'attr' => [
  74.                     'class' => 'button-save',
  75.                 ]
  76.             ])
  77.         ;
  78.     }
  79.     public function configureOptions(OptionsResolver $resolver): void
  80.     {
  81.         $resolver->setDefaults([
  82.             'data_class' => Franchise::class,
  83.         ]);
  84.     }
  85. }