8000 minor #31705 [Form] Throw exception for invalid form buttons name (yc… · symfony/symfony@abc652c · GitHub
[go: up one dir, main page]

Skip to content

Commit abc652c

Browse files
minor #31705 [Form] Throw exception for invalid form buttons name (yceruto)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Form] Throw exception for invalid form buttons name | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See #28969 Commits ------- 6deeaa4 Validating form buttons name
2 parents 8401f27 + 6deeaa4 commit abc652c

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/Symfony/Component/Form/ButtonBuilder.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,7 @@ public function __construct(?string $name, array $options = [])
6161
$this->name = $name;
6262
$this->options = $options;
6363

64-
if (\preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) {
65-
if (isset($matches[1])) {
66-
@trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED);
67-
}
68-
if (isset($matches[2])) {
69-
@trigger_error(sprintf('Using names for buttons that do not contain only letters, digits, underscores ("_"), hyphens ("-") and colons (":") ("%s" given) is deprecated since Symfony 4.3 and will throw an exception in 5.0.', $name), E_USER_DEPRECATED);
70-
}
71-
}
72-
73-
// to be added in 5.0
74-
// FormConfigBuilder::validateName($name);
64+
FormConfigBuilder::validateName($name);
7565
}
7666

7767
/**

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
5.0.0
55
-----
66

7+
* Using names for buttons that do not start with a letter, a digit, or an underscore throw an exception
8+
* Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons throw an exception.
79
* removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType`
810
* removed `getExtendedType()` method of the `FormTypeExtensionInterface`
911
* added static `getExtendedTypes()` method to the `FormTypeExtensionInterface`

src/Symfony/Component/Form/Tests/ButtonBuilderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function testValidNames($name)
4040
}
4141

4242
/**
43-
* @group legacy
43+
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
44+
* @expectedExceptionMessage The name "button[]" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").
4445
*/
4546
public function testNameContainingIllegalCharacters()
4647
{

0 commit comments

Comments
 (0)
0