src/Form/CompanyType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Company;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. //use Symfony\Component\Form\Extension\Core\Type\ChoiceList;
  10. class CompanyType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options)
  13.     {
  14.         $builder
  15.             ->add('business_name',null,[
  16.                 'label'=>'Denomination entreprise'])
  17.             ->add('street_address',null,[
  18.                 'label'=>'Adresse'])
  19.             ->add('state',null,[
  20.                 'label'=>'Ville'])
  21.             ->add('fixe_phone',null,[
  22.                 'label'=>'Tel Fixe',
  23.                 'required'   => false,
  24.                                ])
  25.             ->add('fax_number',null,[
  26.                 'label'=>'Fax',
  27.                 'required'   => false,])
  28.             ->add('mobile')
  29.             ->add('email')
  30.             ->add('website',null,[
  31.                 'label'=>'Site web',
  32.                 'required'   => false,])
  33.             ->add('categories',ChoiceType::class,[
  34.                 'choices'=>$this->getChoices()
  35.             ]
  36.             )
  37.             ->add('city',null,[
  38.                 'label'=>'Commune'])
  39.             ->add('description')
  40.             ->add('contact_name')
  41.             ->add('key_words',null,[
  42.                 'label'=>'Mots cles'])
  43.             ->add('company_presentation')
  44.             ->add('year_established',null,[
  45.                 'label'=>'Date de creation'])
  46.             ->add('facebook'null, [
  47.                 'label'=>'Facebook',
  48.                 'required'   => false,
  49.              ])
  50.             ->add('visite',null,[
  51.                 'label'=>'Souhaitez-vous recevoir notre commercial '])
  52.             ->add('annonce',null,[
  53.                 'label'=>'Souhaitez-vouz avoir une annonce sur les annaires'])
  54.         ;
  55.     }
  56.     public function configureOptions(OptionsResolver $resolver)
  57.     {
  58.         $resolver->setDefaults([
  59.             'data_class' => Company::class,
  60.         ]);
  61.     }
  62.     private function getChoices()
  63.     {
  64.         $choices=Company::CATEGORY;
  65.         $output=[];
  66.         foreach ($choices as $key => $value) {
  67.             $output[$value]=$key;
  68.           
  69.         }
  70.           return $output;
  71.     }
  72. }