<?php
namespace App\Form;
use App\Entity\Catalog;
use App\Entity\LandingContact;
use App\Repository\CatalogRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class LandingContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name')
->add('society')
->add('email')
->add('country')
->add('catalog', EntityType::class, array(
'class' => Catalog::class,
'query_builder' => function (CatalogRepository $er) use ($options) {
return $er->createQueryBuilder('a');
},
'choice_label' => function ($catalog) {
return $catalog->getTitle();
},
"placeholder" => "landing_contact_type.catalog.placeholder",
"multiple" => false,
"label" => false,
"required" => true,
"expanded" => false,
//'by_reference' => false,
));
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => LandingContact::class,
]);
}
}