add 'Length' constraint in forms

This commit is contained in:
Simon Vieille 2023-10-19 20:51:23 +02:00
parent d3f27d97ad
commit c1eb277a6a
Signed by: deblan
GPG key ID: 579388D585F70417
7 changed files with 117 additions and 94 deletions

View file

@ -3,6 +3,7 @@
### Added ### Added
* allow to define templates show before and after a murph collection item * allow to define templates show before and after a murph collection item
* add global batch actions * add global batch actions
* add constraint `Length` in forms
### Fixed ### Fixed
* fix regression on crud sorting * fix regression on crud sorting

View file

@ -138,7 +138,8 @@ class Configuration implements ConfigurationInterface
->end() ->end()
->end() ->end()
->end() ->end()
->end(); ->end()
;
return $treeBuilder; return $treeBuilder;
} }

View file

@ -7,6 +7,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class MenuType extends AbstractType class MenuType extends AbstractType
@ -23,6 +24,7 @@ class MenuType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -37,6 +39,7 @@ class MenuType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );

View file

@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class NavigationAdditionalDomainType extends AbstractType class NavigationAdditionalDomainType extends AbstractType
@ -24,6 +25,7 @@ class NavigationAdditionalDomainType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );

View file

@ -27,6 +27,7 @@ class NavigationType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -41,6 +42,7 @@ class NavigationType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -69,6 +71,7 @@ class NavigationType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -109,7 +112,7 @@ class NavigationType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(['min' => 2, 'max' => 10]), new Length(min: 2, max: 10),
], ],
] ]
); );

View file

@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class NodeType extends AbstractType class NodeType extends AbstractType
@ -29,6 +30,7 @@ class NodeType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -43,6 +45,7 @@ class NodeType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );
@ -82,6 +85,7 @@ class NodeType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );
@ -116,6 +120,9 @@ class NodeType extends AbstractType
return $choices; return $choices;
}), }),
'constraints' => [
new Length(max: 255),
],
] ]
); );

View file

@ -10,6 +10,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\Image;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
class PageType extends AbstractType class PageType extends AbstractType
@ -26,6 +27,7 @@ class PageType extends AbstractType
], ],
'constraints' => [ 'constraints' => [
new NotBlank(), new NotBlank(),
new Length(max: 255),
], ],
] ]
); );
@ -39,6 +41,7 @@ class PageType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );
@ -52,6 +55,7 @@ class PageType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );
@ -65,6 +69,7 @@ class PageType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );
@ -78,6 +83,7 @@ class PageType extends AbstractType
'attr' => [ 'attr' => [
], ],
'constraints' => [ 'constraints' => [
new Length(max: 255),
], ],
] ]
); );