From d811b0e9b50bb628e3e30429b6a4c7a931f0d30b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 19 Nov 2019 08:54:33 +0100 Subject: [PATCH] allow button names to start with uppercase letter --- UPGRADE-4.3.md | 2 +- UPGRADE-5.0.md | 2 +- src/Symfony/Component/Form/ButtonBuilder.php | 2 +- src/Symfony/Component/Form/CHANGELOG.md | 2 +- src/Symfony/Component/Form/Tests/ButtonBuilderTest.php | 8 -------- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index 86155031fa..e3a4ac469d 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -96,7 +96,7 @@ Form ---- * Using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled is deprecated. - * Using names for buttons that do not start with a lowercase letter, a digit, or an underscore is deprecated and will lead to an + * Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated and will lead to an exception in 5.0. * Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons is deprecated and will lead to an exception in 5.0. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 455cd0d62a..302cea6dec 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -110,7 +110,7 @@ Form ---- * Removed support for using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled. - * Using names for buttons that do not start with a lowercase letter, a digit, or an underscore leads to an exception. + * Using names for buttons that do not start with a letter, a digit, or an underscore leads to an exception. * Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons leads to an exception. * Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index bf8e147838..ca6bf78dc9 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -61,7 +61,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface $this->name = $name; $this->options = $options; - if (preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { + if (preg_match('/^([^a-zA-Z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { if (isset($matches[1])) { @trigger_error(sprintf('Using names for buttons that do not start with a lowercase 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); } diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index cf7b8cd8cc..e41c46e907 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -6,7 +6,7 @@ CHANGELOG * added a `symbol` option to the `PercentType` that allows to disable or customize the output of the percent character * Using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled is deprecated. - * Using names for buttons that do not start with a lowercase letter, a digit, or an underscore is deprecated and will lead to an + * Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated and will lead to an exception in 5.0. * Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons is deprecated and will lead to an exception in 5.0. diff --git a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php index 966b2927e9..7bd78896d1 100644 --- a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php @@ -47,14 +47,6 @@ class ButtonBuilderTest extends TestCase $this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]')); } - /** - * @group legacy - */ - public function testNameStartingWithIllegalCharacters() - { - $this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('Button')); - } - public function getInvalidNames() { return [