src/Form/LandingContactType.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Catalog;
  4. use App\Entity\LandingContact;
  5. use App\Repository\CatalogRepository;
  6. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class LandingContactType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('name')
  16.             ->add('society')
  17.             ->add('email')
  18.             ->add('country')
  19.             ->add('catalog'EntityType::class, array(
  20.                 'class' => Catalog::class,
  21.                 'query_builder' => function (CatalogRepository $er) use ($options) {
  22.                     return $er->createQueryBuilder('a');
  23.                 },
  24.                 'choice_label' => function ($catalog) {
  25.                     return $catalog->getTitle();
  26.                 },
  27.                 "placeholder" => "landing_contact_type.catalog.placeholder",
  28.                 "multiple" => false,
  29.                 "label" => false,
  30.                 "required" => true,
  31.                 "expanded" => false,
  32.                 //'by_reference' => false,
  33.             ));
  34.     }
  35.     public function configureOptions(OptionsResolver $resolver): void
  36.     {
  37.         $resolver->setDefaults([
  38.             'data_class' => LandingContact::class,
  39.         ]);
  40.     }
  41. }