deprecate using invalid names for buttons
This commit is contained in:
parent
2cad97b0b5
commit
405aa548eb
|
@ -23,6 +23,10 @@ Config
|
||||||
Form
|
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
|
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is
|
||||||
set to `single_text` is deprecated.
|
set to `single_text` is deprecated.
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,9 @@ Finder
|
||||||
Form
|
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
|
* 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.
|
set to `single_text` is not supported anymore.
|
||||||
* The `getExtendedType()` method was removed from the `FormTypeExtensionInterface`. It is replaced by the the static
|
* The `getExtendedType()` method was removed from the `FormTypeExtensionInterface`. It is replaced by the the static
|
||||||
|
|
|
@ -63,6 +63,18 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||||
|
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->options = $options;
|
$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
|
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`
|
* deprecated using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget`
|
||||||
option is set to `single_text`
|
option is set to `single_text`
|
||||||
* added `block_prefix` option to `BaseType`.
|
* added `block_prefix` option to `BaseType`.
|
||||||
|
|
|
@ -28,7 +28,6 @@ class ButtonBuilderTest extends TestCase
|
||||||
['foo'],
|
['foo'],
|
||||||
['0'],
|
['0'],
|
||||||
[0],
|
[0],
|
||||||
['button[]'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +39,14 @@ class ButtonBuilderTest extends TestCase
|
||||||
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($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()
|
public function getInvalidNames()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
Reference in New Issue