<?php
namespace App\Form;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use App\Entity\Group;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\Extension\Core\Type as Type;
use App\Entity\User;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('company', TextType::class, [
'label' => false,
'mapped' => false,
'constraints' => new Assert\NotBlank(['groups' => 'Registration'])
])
->add('email', EmailType::class, [
'label' => false,
'constraints' => new Assert\Email(['groups' => 'Registration'])
])
->add('username', null, [
'label' => false,
])
->add('plainPassword', PasswordType::class, [
'label' => false,
])
->add('package', EntityType::class, array(
'class' => Group::class,
'constraints' => new Assert\NotNull([
'groups' => 'Registration',
'message' => 'ProszÄ wybraÄ pakiet.'
]),
'mapped' => false,
'label' => false,
// 'placeholder' => 'Plan',
))
->add('country', CountryType::class, [
'constraints' => new Assert\NotNull([
'groups' => 'Registration',
'message' => 'ProszÄ wybraÄ kraj.'
]),
'mapped' => false,
'label' => false,
'placeholder' => 'Kraj',
])
->add('agree', CheckboxType::class, array(
'label' => "form.user.agree",
'mapped' => false,
'constraints' => new Assert\NotBlank(['groups' => 'Registration'])
));
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults(array(
'data_class' => User::class,
'csrf_token_id' => 'registration',
// BC for SF < 2.8
'intention' => 'registration',
));
}
public function getBlockPrefix()
{
return 'app_user_registration';
}
}