Skip to content
Permalink
Browse files

feature #28969 [Form] deprecate using invalid names for buttons (xabbuh)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] deprecate using invalid names for buttons

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #28964
| License       | MIT
| Doc PR        |

Commits
-------

405aa54 deprecate using invalid names for buttons
  • Loading branch information...
fabpot committed Feb 21, 2019
2 parents 5c73900 + 405aa54 commit 02d6c0f22fa165b3c73cc194b8734651ada04dab
@@ -23,6 +23,10 @@ Config
Form
----

* 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.
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
set to `single_text` is deprecated.

@@ -77,7 +77,10 @@ Finder

Form
----


* 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
set to `single_text` is not supported anymore.
* The `getExtendedType()` method was removed from the `FormTypeExtensionInterface`. It is replaced by the the static
@@ -63,6 +63,18 @@ 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 (isset($matches[1])) {
@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);
}
if (isset($matches[2])) {
@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);
}
}
// to be added in 5.0
// FormConfigBuilder::validateName($name);
}
/**
@@ -4,6 +4,10 @@ CHANGELOG
4.3.0
-----

* 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.
* deprecated using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget`
option is set to `single_text`
* added `block_prefix` option to `BaseType`.
@@ -28,7 +28,6 @@ public function getValidNames()
['foo'],
['0'],
[0],
['button[]'],
];
}
@@ -40,6 +39,14 @@ public function testValidNames($name)
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
}
/**
* @group legacy
*/
public function testNameContainingIllegalCharacters()
{
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]'));
}
public function getInvalidNames()
{
return [

0 comments on commit 02d6c0f

Please sign in to comment.
You can’t perform that action at this time.