Skip to content

Commit 9e6ca02

Browse files
committed
feature #1767 Use named arguments to create form constraints (GromNaN)
This PR was merged into the 1.x branch. Discussion ---------- Use named arguments to create form constraints Named arguments on validation constraints are supported since Symfony 5.2, and the `$options` array is deprecated since Symfony 7.3. This is required for the compatibility with Symfony 8.0 Commits ------- a375bc3 Fix form constraint code to use named arguments instead of the deprecated array of options
2 parents 7f693b6 + a375bc3 commit 9e6ca02

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/Maker/MakeRegistrationForm.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
559559
'options_code' => <<<EOF
560560
'mapped' => false,
561561
'constraints' => [
562-
new IsTrue([
563-
'message' => 'You should agree to our terms.',
564-
]),
562+
new IsTrue(
563+
message: 'You should agree to our terms.',
564+
),
565565
],
566566
EOF
567567
],
@@ -573,15 +573,15 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
573573
'mapped' => false,
574574
'attr' => ['autocomplete' => 'new-password'],
575575
'constraints' => [
576-
new NotBlank([
577-
'message' => 'Please enter a password',
578-
]),
579-
new Length([
580-
'min' => 6,
581-
'minMessage' => 'Your password should be at least {{ limit }} characters',
576+
new NotBlank(
577+
message: 'Please enter a password',
578+
),
579+
new Length(
580+
min: 6,
581+
minMessage: 'Your password should be at least {{ limit }} characters',
582582
// max length allowed by Symfony for security reasons
583-
'max' => 4096,
584-
]),
583+
max: 4096,
584+
),
585585
],
586586
EOF
587587
],

templates/resetPassword/ChangePasswordFormType.tpl.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1818
],
1919
'first_options' => [
2020
'constraints' => [
21-
new NotBlank([
22-
'message' => 'Please enter a password',
23-
]),
24-
new Length([
25-
'min' => 12,
26-
'minMessage' => 'Your password should be at least {{ limit }} characters',
21+
new NotBlank(
22+
message: 'Please enter a password',
23+
),
24+
new Length(
25+
min: 12,
26+
minMessage: 'Your password should be at least {{ limit }} characters',
2727
// max length allowed by Symfony for security reasons
28-
'max' => 4096,
29-
]),
28+
max: 4096,
29+
),
3030
new PasswordStrength(),
3131
new NotCompromisedPassword(),
3232
],

templates/resetPassword/ResetPasswordRequestFormType.tpl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1212
->add('<?= $email_field ?>', EmailType::class, [
1313
'attr' => ['autocomplete' => 'email'],
1414
'constraints' => [
15-
new NotBlank([
16-
'message' => 'Please enter your email',
17-
]),
15+
new NotBlank(
16+
message: 'Please enter your email',
17+
),
1818
],
1919
])
2020
;

0 commit comments

Comments
 (0)