<?php declare(strict_types=1);
namespace App\Form\Type;
use App\Entity\Country;
use App\Model\ContentReportData;
use App\Repository\CountryRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ContentReportDataType extends AbstractType
{
/**
* @param array<mixed> $options
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName', TextType::class, [
'label' => 'form.first_name',
])
->add('lastName', TextType::class, [
'label' => 'form.last_name',
])
->add('stageName', TextType::class, [
'label' => 'form.stage_name',
'required' => false,
])
->add('companyName', TextType::class, [
'label' => 'form.company_name',
'required' => false,
])
->add('commercialRegistrationNumber', TextType::class, [
'label' => 'form.commercial_registration_number',
'required' => false,
])
->add('email', TextType::class, [
'label' => 'form.email',
])
->add('phone', TextType::class, [
'label' => 'form.phone',
])
->add('address', TextType::class, [
'label' => 'form.address',
])
->add('addressAdditional', TextType::class, [
'label' => 'form.address_additional',
'required' => false,
])
->add('zipCode', TextType::class, [
'label' => 'form.zip_code',
])
->add('city', TextType::class, [
'label' => 'form.city',
])
->add('country', EntityType::class, [
'label' => 'form.country',
'class' => Country::class,
'choice_label' => 'name',
'query_builder' => function (CountryRepository $er) {
return $er->filter(['order_by' => [['field' => 'name', 'order' => 'asc']]]);
},
'placeholder' => 'form.chose_country_placeholder',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'translation_domain' => 'content_report',
'data_class' => ContentReportData::class,
]);
}
}