From 25a9a6ee1a94ebe190e53eeeac065bcce522be76 Mon Sep 17 00:00:00 2001 From: L91 Date: Mon, 3 Apr 2017 10:26:25 +0200 Subject: [PATCH] Added missing default validation constraints (#58) * fix default validation constraints * fix registration type --- Form/Type/ProfileAddressType.php | 3 ++- Form/Type/ProfileContactAddressType.php | 3 ++- Form/Type/RegistrationType.php | 7 +++++++ Resources/config/validation.xml | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Form/Type/ProfileAddressType.php b/Form/Type/ProfileAddressType.php index 48f10224..525c2628 100644 --- a/Form/Type/ProfileAddressType.php +++ b/Form/Type/ProfileAddressType.php @@ -15,6 +15,7 @@ use Sulu\Bundle\ContactBundle\Entity\Country; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Intl\Intl; @@ -30,7 +31,7 @@ class ProfileAddressType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('primaryAddress', 'hidden', ['data' => 1]); + $builder->add('primaryAddress', HiddenType::class, ['data' => 1]); $builder->add('street', TextType::class, ['required' => false]); $builder->add('number', TextType::class, ['required' => false]); diff --git a/Form/Type/ProfileContactAddressType.php b/Form/Type/ProfileContactAddressType.php index 8e2850e3..10814872 100644 --- a/Form/Type/ProfileContactAddressType.php +++ b/Form/Type/ProfileContactAddressType.php @@ -13,6 +13,7 @@ use Sulu\Bundle\ContactBundle\Entity\ContactAddress; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -24,7 +25,7 @@ class ProfileContactAddressType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('address', new $options['address_type'](), $options['address_type_options']); - $builder->add('main', 'hidden', [ + $builder->add('main', HiddenType::class, [ 'required' => false, 'data' => 1, ]); diff --git a/Form/Type/RegistrationType.php b/Form/Type/RegistrationType.php index d93b64b3..a5a37218 100644 --- a/Form/Type/RegistrationType.php +++ b/Form/Type/RegistrationType.php @@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; /** * Create the registration form type. @@ -38,6 +39,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) PasswordType::class, [ 'mapped' => false, + 'constraints' => new NotBlank([ + 'groups' => ['registration'], + ]), ] ); @@ -53,6 +57,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) [ 'mapped' => false, 'required' => true, + 'constraints' => new NotBlank([ + 'groups' => ['registration'], + ]), ] ); diff --git a/Resources/config/validation.xml b/Resources/config/validation.xml index f1cee5de..a7366d95 100644 --- a/Resources/config/validation.xml +++ b/Resources/config/validation.xml @@ -32,6 +32,12 @@ + + +