<?php
namespace AppBundle\Form\Customer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type as Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class RegisterType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
// inherit data fields frpm the customer type
->add('customer', CustomerType::class, [
'data_class' => 'AppBundle\Entity\Customer',
])
->add('plainPassword', Type\RepeatedType::class, [
'type' => Type\PasswordType::class,
'invalid_message' => 'security.password.must_match',
'required' => true,
'first_options' => ['label' => 'security.password'],
'second_options' => ['label' => 'security.password.repeated'],
'options' => [
'attr' => [
'class' => 'u-full-width',
],
],
'constraints' => [
new Assert\NotBlank([
'message' => 'security.password.not_blank',
]),
new Assert\Length([
'min' => 6,
'minMessage' => 'security.password.min_length',
]),
],
])
->add('datenschutz', Type\CheckboxType::class, [
'label' => '',
'required' => true,
'mapped' => false,
])
->add('register', Type\SubmitType::class, [
'label' => 'customer.register.button',
'attr' => ['class' => 'button button-primary'],
]);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'AppBundle\Entity\Customer',
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'appbundle_customer_register';
}
}