Skip to content

Commit

Permalink
bug #34448 [Form] allow button names to start with uppercase letter (…
Browse files Browse the repository at this point in the history
…xabbuh)

This PR was merged into the 4.3 branch.

Discussion
----------

[Form] allow button names to start with uppercase letter

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

d811b0e allow button names to start with uppercase letter
  • Loading branch information
fabpot committed Nov 19, 2019
2 parents 90431e7 + d811b0e commit a7c66db
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion UPGRADE-4.3.md
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-5.0.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/ButtonBuilder.php
Expand Up @@ -61,7 +61,7 @@ public function __construct(?string $name, array $options = [])
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/CHANGELOG.md
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
Expand Up @@ -47,14 +47,6 @@ public function testNameContainingIllegalCharacters()
$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 [
Expand Down

0 comments on commit a7c66db

Please sign in to comment.