src/App/Form/Type/ContentReportDataType.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Form\Type;
  3. use App\Entity\Country;
  4. use App\Model\ContentReportData;
  5. use App\Repository\CountryRepository;
  6. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class ContentReportDataType extends AbstractType
  12. {
  13.     /**
  14.      * @param array<mixed> $options
  15.      */
  16.     public function buildForm(FormBuilderInterface $builder, array $options): void
  17.     {
  18.         $builder
  19.             ->add('firstName'TextType::class, [
  20.                 'label' => 'form.first_name',
  21.             ])
  22.             ->add('lastName'TextType::class, [
  23.                 'label' => 'form.last_name',
  24.             ])
  25.             ->add('stageName'TextType::class, [
  26.                 'label' => 'form.stage_name',
  27.                 'required' => false,
  28.             ])
  29.             ->add('companyName'TextType::class, [
  30.                 'label' => 'form.company_name',
  31.                 'required' => false,
  32.             ])
  33.             ->add('commercialRegistrationNumber'TextType::class, [
  34.                 'label' => 'form.commercial_registration_number',
  35.                 'required' => false,
  36.             ])
  37.             ->add('email'TextType::class, [
  38.                 'label' => 'form.email',
  39.             ])
  40.             ->add('phone'TextType::class, [
  41.                 'label' => 'form.phone',
  42.             ])
  43.             ->add('address'TextType::class, [
  44.                 'label' => 'form.address',
  45.             ])
  46.             ->add('addressAdditional'TextType::class, [
  47.                 'label' => 'form.address_additional',
  48.                 'required' => false,
  49.             ])
  50.             ->add('zipCode'TextType::class, [
  51.                 'label' => 'form.zip_code',
  52.             ])
  53.             ->add('city'TextType::class, [
  54.                 'label' => 'form.city',
  55.             ])
  56.             ->add('country'EntityType::class, [
  57.                 'label' => 'form.country',
  58.                 'class' => Country::class,
  59.                 'choice_label' => 'name',
  60.                 'query_builder' => function (CountryRepository $er) {
  61.                     return $er->filter(['order_by' => [['field' => 'name''order' => 'asc']]]);
  62.                 },
  63.                 'placeholder' => 'form.chose_country_placeholder',
  64.             ])
  65.         ;
  66.     }
  67.     public function configureOptions(OptionsResolver $resolver): void
  68.     {
  69.         $resolver->setDefaults([
  70.             'translation_domain' => 'content_report',
  71.             'data_class' => ContentReportData::class,
  72.         ]);
  73.     }
  74. }