src/AppBundle/Form/Customer/RegisterType.php line 11

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Form\Customer;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type as Type;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. class RegisterType extends AbstractType
  9. {
  10.     /**
  11.      * {@inheritdoc}
  12.      */
  13.     public function buildForm(FormBuilderInterface $builder, array $options)
  14.     {
  15.         $builder
  16.             // inherit data fields frpm the customer type
  17.             ->add('customer'CustomerType::class, [
  18.                 'data_class' => 'AppBundle\Entity\Customer',
  19.             ])
  20.             ->add('plainPassword'Type\RepeatedType::class, [
  21.                 'type' => Type\PasswordType::class,
  22.                 'invalid_message' => 'security.password.must_match',
  23.                 'required' => true,
  24.                 'first_options' => ['label' => 'security.password'],
  25.                 'second_options' => ['label' => 'security.password.repeated'],
  26.                 'options' => [
  27.                     'attr' => [
  28.                         'class' => 'u-full-width',
  29.                     ],
  30.                 ],
  31.                 'constraints' => [
  32.                     new Assert\NotBlank([
  33.                         'message' => 'security.password.not_blank',
  34.                     ]),
  35.                     new Assert\Length([
  36.                         'min' => 6,
  37.                         'minMessage' => 'security.password.min_length',
  38.                     ]),
  39.                 ],
  40.             ])
  41.             ->add('datenschutz'Type\CheckboxType::class, [
  42.                 'label' => '',
  43.                 'required' => true,
  44.                 'mapped' => false,
  45.             ])
  46.             ->add('register'Type\SubmitType::class, [
  47.                 'label' => 'customer.register.button',
  48.                 'attr' => ['class' => 'button button-primary'],
  49.             ]);
  50.     }
  51.     /**
  52.      * {@inheritdoc}
  53.      */
  54.     public function configureOptions(OptionsResolver $resolver)
  55.     {
  56.         $resolver->setDefaults([
  57.             'data_class' => 'AppBundle\Entity\Customer',
  58.         ]);
  59.     }
  60.     /**
  61.      * {@inheritdoc}
  62.      */
  63.     public function getBlockPrefix()
  64.     {
  65.         return 'appbundle_customer_register';
  66.     }
  67. }