Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6deeaa4

Browse files
committed
Validating form buttons name
1 parent 2bf74ce commit 6deeaa4

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

911
4.3.0

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)