Skip to content

Commit c6c56e5

Browse files
committed
[Form] Fix BC break introduced in #14403
1 parent dd7e05d commit c6c56e5

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,10 @@
319319

320320
{%- block widget_attributes -%}
321321
id="{{ id }}" name="{{ full_name }}"
322+
{%- if read_only %} readonly="readonly"{% endif -%}
322323
{%- if disabled %} disabled="disabled"{% endif -%}
323324
{%- if required %} required="required"{% endif -%}
324-
{%- for attrname, attrvalue in attr -%}
325+
{%- for attrname, attrvalue in attr if 'readonly' != attrname -%}
325326
{{- " " -}}
326327
{%- if attrname in ['placeholder', 'title'] -%}
327328
{{- attrname }}="{{ translation_domain is same as(false) ? attrvalue : attrvalue|trans({}, translation_domain) }}"

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/widget_attributes.html.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"<?php if ($disabled): ?> disabled="disabled"<?php endif ?>
1+
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"<?php if ($read_only): ?> readonly="readonly" <?php endif ?>
2+
3+
<?php if ($disabled): ?> disabled="disabled"<?php endif ?>
24
<?php if ($required): ?> required="required"<?php endif ?>
35
<?php foreach ($attr as $k => $v): ?>
6+
<?php if ('readonly' === $k) { continue; } ?>
47
<?php if (in_array($k, array('placeholder', 'title'), true)): ?>
58
<?php printf(' %s="%s"', $view->escape($k), $view->escape(false !== $translation_domain ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
69
<?php elseif ($v === true): ?>

src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,7 @@ public function testWidgetAttributes()
24302430
$html = $this->renderWidget($form->createView());
24312431

24322432
// compare plain HTML to check the whitespace
2433-
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar form-control" data-foo="bar" value="value" />', $html);
2433+
$this->assertSame('<input type="text" id="text" name="text" readonly="readonly" disabled="disabled" required="required" maxlength="10" pattern="\d+" class="foobar form-control" data-foo="bar" value="value" />', $html);
24342434
}
24352435

24362436
public function testWidgetAttributeNameRepeatedIfTrue()

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ public function testWidgetAttributes()
23732373
$html = $this->renderWidget($form->createView());
23742374

23752375
// compare plain HTML to check the whitespace
2376-
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html);
2376+
$this->assertSame('<input type="text" id="text" name="text" readonly="readonly" disabled="disabled" required="required" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html);
23772377
}
23782378

23792379
public function testWidgetAttributeNameRepeatedIfTrue()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy