src/Form/Security/StepperType.php line 17
<?php
namespace App\Form\Security;
use App\Service\Twig\Strings;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\NotBlank;
class StepperType extends AbstractType
{
public function __construct(
private readonly Strings $strings
){}
/**
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("email_cannot_be_empty")
])
])
->add('phone', TextType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("phone_cannot_be_empty")
])
])
->add('firstName', TextType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("name_surname_cannot_be_empty")
])
])
->add('lastName', TextType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("name_surname_cannot_be_empty")
])
])
->add('companyName', TextType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("company_cannot_be_empty")
])
])
->add('pin', TextType::class, [
"label" => false,
"required" => false,
"constraints" => new NotBlank([
"message" => $this->strings->getTranslationString("pin_cannot_be_empty")
])
])
->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
"invalid_message" => $this->strings->getTranslationString("passwords_doesnt_match"),
'first_options' => array(
'label' => 'Password',
"invalid_message" => $this->strings->getTranslationString("passwords_doesnt_match")
),
'second_options' => array(
'label' => 'Repeat Password',
"invalid_message" => $this->strings->getTranslationString("passwords_doesnt_match")
),
"constraints" => [
new NotBlank([
"message" => $this->strings->getTranslationString("password_cannot_be_empty")
])
],
"required" => false
))
->add('agreeTerms', CheckboxType::class, array(
'mapped' => false,
'constraints' => new IsTrue([
"message" => $this->strings->getTranslationString("please_accept_terms_text")
]),
'attr' => array('class'=>'custom-control-input'),
'required' => false
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => NULL,
'csrf_protection' => true
));
}
}