<?php
namespace App\Form;
use App\Entity\Person;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RegistrationPersonType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('firstName',TextType::class, ['required' => true, 'label' => 'person.myfirstname'])
->add('lastName',TextType::class, ['required' => true, 'label' => 'person.mylastname'])
;
if ($options['with_phone']) {
$builder
->add('phone', TextType::class, ['required' => true, 'label' => 'person.phone']);
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Person::class,
'csrf_protection' => false,
'with_phone' => false
]);
}
}