Skip to content

Commit 027b8c8

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: fixed deprecated messages in tests [HttpCache] Unlink tmp file on error Added LB translation for #26327 (Errors sign for people that do not see colors) [TwigBridge] Fix rendering of currency by MoneyType [HttpKernel] DumpDataCollector: do not flush when a dumper is provided
2 parents caee758 + f09fd1b commit 027b8c8

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php echo str_replace('{{ widget }}', $view['form']->block($form, 'form_widget_simple'), $money_pattern) ?>
1+
<?php echo $view['form']->formEncodeCurrency($money_pattern, $view['form']->block($form, 'form_widget_simple')) ?>

Templating/Helper/FormHelper.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,20 @@ public function humanize($text)
240240
{
241241
return $this->renderer->humanize($text);
242242
}
243+
244+
/**
245+
* @internal
246+
*/
247+
public function formEncodeCurrency($text, $widget = '')
248+
{
249+
if ('UTF-8' === $charset = $this->getCharset()) {
250+
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
251+
} else {
252+
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
253+
$text = iconv('UTF-8', $charset, $text);
254+
$widget = iconv('UTF-8', $charset, $widget);
255+
}
256+
257+
return str_replace('{{ widget }}', $widget, $text);
258+
}
243259
}

Tests/Templating/Helper/FormHelperDivLayoutTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
8181
$this->assertSame('<form name="form" method="get" action="0">', $html);
8282
}
8383

84+
public function testMoneyWidgetInIso()
85+
{
86+
$this->engine->setCharset('ISO-8859-1');
87+
88+
$view = $this->factory
89+
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
90+
->createView()
91+
;
92+
93+
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
94+
}
95+
8496
protected function renderForm(FormView $view, array $vars = array())
8597
{
8698
return (string) $this->engine->get('form')->form($view, $vars);

0 commit comments

Comments
 (0)