Skip to content

Commit 563e812

Browse files
Merge branch '7.2' into 7.3
* 7.2: [Validator] Review Croatian translation [Validator] Review "twig template" translation Update Mailer Azure bridge API docs link Provide missing translations thanks to Gemini [DependencyInjection] Make `DefinitionErrorExceptionPass` consider `IGNORE_ON_UNINITIALIZED_REFERENCE` and `RUNTIME_EXCEPTION_ON_INVALID_REFERENCE` the same [FrameworkBundle] Fix declaring fiel-attr tags in xml config files [WebLink] Hint that prerender is deprecated [DependencyInjection] Fix missing binding for ServiceCollectionInterface when declaring a service subscriber
2 parents 1246ee2 + 7627f00 commit 563e812

File tree

7 files changed

+58
-17
lines changed

7 files changed

+58
-17
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode, callable $enableI
257257
->arrayNode('field_attr')
258258
->performNoDeepMerging()
259259
->normalizeKeys(false)
260+
->useAttributeAsKey('name')
260261
->scalarPrototype()->end()
261262
->defaultValue(['data-controller' => 'csrf-protection'])
262263
->end()

Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<xsd:attribute name="field-name" type="xsd:string" />
8181
</xsd:complexType>
8282

83-
<xsd:complexType name="field_attr">
83+
<xsd:complexType name="field_attr" mixed="true">
8484
<xsd:attribute name="name" type="xsd:string" use="required"/>
8585
</xsd:complexType>
8686

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'annotations' => false,
5+
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
8+
'csrf_protection' => [
9+
'enabled' => true,
10+
],
11+
'form' => [
12+
'csrf_protection' => [
13+
'field-attr' => [
14+
'data-foo' => 'bar',
15+
'data-bar' => 'baz',
16+
],
17+
],
18+
],
19+
'session' => [
20+
'storage_factory_id' => 'session.storage.factory.native',
21+
],
22+
]);

Tests/DependencyInjection/Fixtures/xml/form_csrf_sets_field_name.xml renamed to Tests/DependencyInjection/Fixtures/xml/form_csrf_field_attr.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
<framework:config http-method-override="false" handle-all-throwables="true">
1010
<framework:annotations enabled="false" />
1111
<framework:php-errors log="true" />
12-
<framework:csrf-protection field-name="_custom" />
12+
<framework:csrf-protection enabled="true" />
13+
<framework:form>
14+
<framework:csrf-protection>
15+
<framework:field-attr name="data-foo">bar</framework:field-attr>
16+
<framework:field-attr name="data-bar">baz</framework:field-attr>
17+
</framework:csrf-protection>
18+
</framework:form>
1319
<framework:session storage-factory-id="session.storage.factory.native" />
1420
</framework:config>
1521
</container>

Tests/DependencyInjection/Fixtures/xml/form_csrf_under_form_sets_field_name.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
framework:
2+
annotations: false
3+
http_method_override: false
4+
handle_all_throwables: true
5+
php_errors:
6+
log: true
7+
csrf_protection:
8+
enabled: true
9+
form:
10+
csrf_protection:
11+
enabled: true
12+
field_attr:
13+
data-foo: bar
14+
data-bar: baz
15+
session:
16+
storage_factory_id: session.storage.factory.native

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,17 @@ public function testFormsCanBeEnabledWithoutCsrfProtection()
14911491
$this->assertFalse($container->getParameter('form.type_extension.csrf.enabled'));
14921492
}
14931493

1494+
public function testFormCsrfFieldAttr()
1495+
{
1496+
$container = $this->createContainerFromFile('form_csrf_field_attr');
1497+
1498+
$expected = [
1499+
'data-foo' => 'bar',
1500+
'data-bar' => 'baz',
1501+
];
1502+
$this->assertSame($expected, $container->getParameter('form.type_extension.csrf.field_attr'));
1503+
}
1504+
14941505
public function testStopwatchEnabledWithDebugModeEnabled()
14951506
{
14961507
$container = $this->createContainerFromFile('default_config', [

0 commit comments

Comments
 (0)