Skip to content

Commit

Permalink
Added missing default validation constraints (#58)
Browse files Browse the repository at this point in the history
* fix default validation constraints

* fix registration type
  • Loading branch information
alexander-schranz authored and wachterjohannes committed Apr 3, 2017
1 parent 63e4d48 commit 25a9a6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Form/Type/ProfileAddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
Expand Down
3 changes: 2 additions & 1 deletion Form/Type/ProfileContactAddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
]);
Expand Down
7 changes: 7 additions & 0 deletions Form/Type/RegistrationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -38,6 +39,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
PasswordType::class,
[
'mapped' => false,
'constraints' => new NotBlank([
'groups' => ['registration'],
]),
]
);

Expand All @@ -53,6 +57,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
[
'mapped' => false,
'required' => true,
'constraints' => new NotBlank([
'groups' => ['registration'],
]),
]
);

Expand Down
6 changes: 6 additions & 0 deletions Resources/config/validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
</constraint>
</property>
<property name="email">
<constraint name="NotBlank">
<option name="groups">
<value>registration</value>
<value>completion</value>
</option>
</constraint>
<constraint name="Email">
<option name="groups">
<value>registration</value>
Expand Down

0 comments on commit 25a9a6e

Please sign in to comment.