src/Form/LocationType.php line 14

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Location;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Contracts\Translation\TranslatorInterface;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  11. class LocationType extends AbstractType
  12. {
  13.     public function __construct(private TranslatorInterface $translator)
  14.     {
  15.     }
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('country'CountryType::class, [
  20.                 'label' => $this->translator->trans('Pays'),
  21.                 'required' => true,
  22.                 'attr' => [
  23.                     'class' => 'form-control',
  24.                     'placeholder' => ''
  25.                 ],
  26.                 'help' => ''
  27.             ])
  28.             ->add('wilaya'ChoiceType::class, [
  29.                 'label' => $this->translator->trans('Wilaya'),
  30.                 'required' => true,
  31.                 'attr' => [
  32.                     'class' => 'form-control',
  33.                     'placeholder' => ''
  34.                 ],
  35.                 'help' => '',
  36.                 'choices' => [
  37.                     'Adrar' => 'Adrar',
  38.                     'Chlef' => 'Chlef',
  39.                     'Laghouat' => 'Laghouat',
  40.                     'Oum El Bouaghi' => 'Oum El Bouaghi',
  41.                     'Batna' => 'Batna',
  42.                     'Béjaïa' => 'Béjaïa',
  43.                     'Biskra' => 'Biskra',
  44.                     'Béchar' => 'Béchar',
  45.                     'Blida' => 'Blida',
  46.                     'Bouira' => 'Bouira',
  47.                     'Tamanrasset' => 'Tamanrasset',
  48.                     'Tébessa' => 'Tébessa',
  49.                     'Tlemcen' => 'Tlemcen',
  50.                     'Tiaret' => 'Tiaret',
  51.                     'Tizi Ouzou' => 'Tizi Ouzou',
  52.                     'Alger' => 'Alger',
  53.                     'Djelfa' => 'Djelfa',
  54.                     'Jijel' => 'Jijel',
  55.                     'Sétif' => 'Sétif',
  56.                     'Saïda' => 'Saïda',
  57.                     'Skikda' => 'Skikda',
  58.                     'Sidi Bel Abbès' => 'Sidi Bel Abbès',
  59.                     'Annaba' => 'Annaba',
  60.                     'Guelma' => 'Guelma',
  61.                     'Constantine' => 'Constantine',
  62.                     'Médéa' => 'Médéa',
  63.                     'Mostaganem' => 'Mostaganem',
  64.                     'M\'Sila' => 'M\'Sila',
  65.                     'Mascara' => 'Mascara',
  66.                     'Ouargla' => 'Ouargla',
  67.                     'Oran' => 'Oran',
  68.                     'El Bayadh' => 'El Bayadh',
  69.                     'Illizi' => 'Illizi',
  70.                     'Bordj Bou Arreridj' => 'Bordj Bou Arreridj',
  71.                     'Boumerdès' => 'Boumerdès',
  72.                     'El Tarf' => 'El Tarf',
  73.                     'Tindouf' => 'Tindouf',
  74.                     'Tissemsilt' => 'Tissemsilt',
  75.                     'El Oued' => 'El Oued',
  76.                     'Khenchela' => 'Khenchela',
  77.                     'Souk Ahras' => 'Souk Ahras',
  78.                     'Tipaza' => 'Tipaza',
  79.                     'Mila' => 'Mila',
  80.                     'Aïn Defla' => 'Aïn Defla',
  81.                     'Naâma' => 'Naâma',
  82.                     'Aïn Témouchent' => 'Aïn Témouchent',
  83.                     'Ghardaïa' => 'Ghardaïa',
  84.                     'Relizane' => 'Relizane',
  85.                 ]
  86.             ])
  87.             ->add('city'TextType::class, [
  88.                 'label' => $this->translator->trans('Ville'),
  89.                 'required' => false,
  90.                 'attr' => [
  91.                     'class' => 'form-control',
  92.                     'placeholder' => ''
  93.                 ],
  94.                 'help' => ''
  95.             ])
  96.             ->add('street'TextType::class, [
  97.                 'label' => $this->translator->trans('Rue'),
  98.                 'required' => false,
  99.                 'attr' => [
  100.                     'class' => 'form-control',
  101.                     'placeholder' => ''
  102.                 ],
  103.                 'help' => ''
  104.             ])
  105.             ->add('nhouse'TextType::class, [
  106.                 'label' => $this->translator->trans('Numéro de maison'),
  107.                 'required' => false,
  108.                 'attr' => [
  109.                     'class' => 'form-control',
  110.                     'placeholder' => ''
  111.                 ],
  112.                 'help' => ''
  113.             ])
  114.             ->add('zipcode'TextType::class, [
  115.                 'label' => $this->translator->trans('Code postal'),
  116.                 'required' => false,
  117.                 'attr' => [
  118.                     'class' => 'form-control',
  119.                     'placeholder' => ''
  120.                 ],
  121.                 'help' => ''
  122.             ])
  123.             // ->add('lat')
  124.             // ->add('lon')
  125.         ;
  126.     }
  127.     public function configureOptions(OptionsResolver $resolver): void
  128.     {
  129.         $resolver->setDefaults([
  130.             'data_class' => Location::class,
  131.         ]);
  132.     }
  133. }