src/Form/SimulPanneauxFormType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\SimulSitePanneaux;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ButtonType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  9. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Form\Extension\Core\Type\DateType;
  13. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. class SimulPanneauxFormType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options)
  18.     {
  19.         $builder
  20.             ->add('habitant'ChoiceType::class, [
  21.                 'choices'=>[
  22.                   'Propriétaire'=>'propriétaire',
  23.                   'Locataire'=>'locataire'
  24.                 ],
  25.             ])
  26.             ->add('cp'IntegerType::Class,[
  27.                 'required'=>true,
  28.                 'label'=>'Code Postal'
  29.             ])
  30.             ->add('domicile'ChoiceType::class, [
  31.                 'choices'=>[
  32.                     'Maison'=>'Maison',
  33.                     'Appartement'=>'Appartement'
  34.                 ],
  35.             ])
  36.             ->add('date_construction'ChoiceType::class, [
  37.                 'choices'=>[
  38.                     'Avant 1960'=>'<1960',
  39.                     '1960-1974'=>'1960-1974',
  40.                     '1974-1982'=>'1974-1982',
  41.                     '1983-1989'=>'1983-1989',
  42.                     '1990-2000'=>'1990-2000',
  43.                     '2001-2004'=>'2001-2004',
  44.                     '2005-2012'=>'2005-2012',
  45.                     'Maison RT 2012'=>'Maison RT 2012'
  46.                 ],
  47.             ])
  48.             ->add('chauffage'ChoiceType::class, [
  49.                 'choices'=>[
  50.                     'Fioul'=>'Fioul',
  51.                     'Gaz'=>'Gaz',
  52.                     'Electricité'=>'Electricité',
  53.                     'Autres'=>'Autres'
  54.                 ],
  55.             ])
  56.             ->add('orientation_toiture'ChoiceType::class, [
  57.                 'choices'=>[
  58.                     'Est'=>'Est',
  59.                     'Sud-Est'=>'Sud-Est',
  60.                     'Sud'=>'Sud',
  61.                     'Sud-Ouest'=>'Sud-Ouest',
  62.                     'Ouest'=>'Ouest'
  63.                 ],
  64.             ])
  65.             ->add('surface_pan_toiture'IntegerType::Class, [
  66.                 'attr'=>['min'=>10,
  67.                     'max'=>100],
  68.                 'required'=>false
  69.             ])
  70.             ->add('inclinaison_toiture'ChoiceType::class, [
  71.                 'choices'=>[
  72.                     'Toiture plate'=>'0',
  73.                     '10°'=>'10',
  74.                     '20°'=>'20',
  75.                     '30°'=>'30',
  76.                     '45°'=>'45'
  77.                 ],
  78.             ])
  79.             ->add('conso_elec_mois',ChoiceType::class, [
  80.                 'choices'=>[
  81.                     '6000'=>'6000',
  82.                     '7000'=>'7000',
  83.                     '8000'=>'8000',
  84.                     '9000'=>'9000',
  85.                     '10000'=>'10000',
  86.                     '11000'=>'11000',
  87.                     '12000'=>'12000',
  88.                     '13000'=>'13000',
  89.                     '14000'=>'14000',
  90.                     '15000'=>'15000',
  91.                     '16000'=>'16000',
  92.                     '17000'=>'17000',
  93.                     '18000'=>'18000'
  94.                 ],
  95.             ])
  96.             ->add('nom',TextType::Class)
  97.             ->add('prenom',TextType::Class)
  98.             ->add('mail',EmailType::Class,[
  99.                 'required'=>false
  100.             ])
  101.             ->add('tel',TextType::Class,[
  102.                 'required'=>false
  103.             ])
  104.             ->add('retour',ButtonType::Class,[
  105.                 'attr'=>['class'=>'btn btn-secondary','onClick'=>'window.history.back();']
  106.             ])
  107.             ->add('submit',SubmitType::class)
  108.             ->add('random_simul_id'TextType::class,[
  109.                 'attr'=>['class'=>'hidden'],
  110.                 'label'=>false
  111.             ])
  112.         ;
  113.     }
  114.     public function configureOptions(OptionsResolver $resolver)
  115.     {
  116.         $resolver->setDefaults([
  117.             'data_class' => SimulSitePanneaux::class,
  118.             'csrf_protection' => false,
  119.             // the name of the hidden HTML field that stores the token
  120.             'csrf_field_name' => '_token',
  121.             // an arbitrary string used to generate the value of the token
  122.             // using a different string for each form improves its security
  123.             'csrf_token_id'   => 'simul'
  124.         ]);
  125.     }
  126. }