Skip to content

Commit 7596e74

Browse files
Merge branch '3.4' into 4.0
* 3.4: fix merge fix merge fixed tests
2 parents d6dfce8 + 36a48d9 commit 7596e74

8 files changed

+54
-71
lines changed

Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,6 @@
3232
{% endif %}
3333
{%- endblock money_widget %}
3434

35-
{% block percent_widget -%}
36-
<div class="input-group">
37-
{{- block('form_widget_simple') -}}
38-
<span class="input-group-addon">%</span>
39-
</div>
40-
{%- endblock percent_widget %}
41-
42-
{% block datetime_widget -%}
43-
{% if widget == 'single_text' %}
44-
{{- block('form_widget_simple') -}}
45-
{% else -%}
46-
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
47-
<div {{ block('widget_container_attributes') }}>
48-
{{- form_errors(form.date) -}}
49-
{{- form_errors(form.time) -}}
50-
{{- form_widget(form.date, { datetime: true } ) -}}
51-
{{- form_widget(form.time, { datetime: true } ) -}}
52-
</div>
53-
{%- endif %}
54-
{%- endblock datetime_widget %}
55-
56-
{% block date_widget -%}
57-
{% if widget == 'single_text' %}
58-
{{- block('form_widget_simple') -}}
59-
{% else -%}
60-
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
61-
{% if datetime is not defined or not datetime -%}
62-
<div {{ block('widget_container_attributes') -}}>
63-
{%- endif %}
64-
{{- date_pattern|replace({
65-
'{{ year }}': form_widget(form.year),
66-
'{{ month }}': form_widget(form.month),
67-
'{{ day }}': form_widget(form.day),
68-
})|raw -}}
69-
{% if datetime is not defined or not datetime -%}
70-
</div>
71-
{%- endif -%}
72-
{% endif %}
73-
{%- endblock date_widget %}
74-
75-
{% block time_widget -%}
76-
{% if widget == 'single_text' %}
77-
{{- block('form_widget_simple') -}}
78-
{% else -%}
79-
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
80-
{% if datetime is not defined or false == datetime -%}
81-
<div {{ block('widget_container_attributes') -}}>
82-
{%- endif -%}
83-
{{- form_widget(form.hour) }}{% if with_minutes %}:{{ form_widget(form.minute) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
84-
{% if datetime is not defined or false == datetime -%}
85-
</div>
86-
{%- endif -%}
87-
{% endif %}
88-
{%- endblock time_widget %}
89-
90-
{% block choice_widget_collapsed -%}
91-
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
92-
{%- endblock choice_widget_collapsed %}
93-
9435
{% block checkbox_widget -%}
9536
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
9637
{% if 'checkbox-inline' in parent_label_class %}

Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
<div class="input-group{{ group_class|default('') }}">
1010
{%- if prepend -%}
1111
<div class="input-group-prepend">
12-
<span class="input-group-text">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
12+
<span class="input-group-text">{{ money_pattern|form_encode_currency }}</span>
1313
</div>
1414
{%- endif -%}
1515
{{- block('form_widget_simple') -}}
1616
{%- if append -%}
1717
<div class="input-group-append">
18-
<span class="input-group-text">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
18+
<span class="input-group-text">{{ money_pattern|form_encode_currency }}</span>
1919
</div>
2020
{%- endif -%}
2121
</div>

Resources/views/Form/bootstrap_base_layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
{% if prepend or append %}
1414
<div class="input-group{{ group_class|default('') }}">
1515
{% if prepend %}
16-
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
16+
<span class="input-group-addon">{{ money_pattern|form_encode_currency }}</span>
1717
{% endif %}
1818
{{- block('form_widget_simple') -}}
1919
{% if append %}
20-
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
20+
<span class="input-group-addon">{{ money_pattern|form_encode_currency }}</span>
2121
{% endif %}
2222
</div>
2323
{% else %}

Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
{% set prepend = '{{' == money_pattern[0:2] %}
2828
{% if not prepend %}
2929
<div class="small-3 large-2 columns">
30-
<span class="prefix">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
30+
<span class="prefix">{{ money_pattern|form_encode_currency }}</span>
3131
</div>
3232
{% endif %}
3333
<div class="small-9 large-10 columns">
3434
{{- block('form_widget_simple') -}}
3535
</div>
3636
{% if prepend %}
3737
<div class="small-3 large-2 columns">
38-
<span class="postfix">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
38+
<span class="postfix">{{ money_pattern|form_encode_currency }}</span>
3939
</div>
4040
{% endif %}
4141
</div>

Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ public function testMoneyWidgetInIso()
8282
__DIR__.'/Fixtures/templates/form',
8383
)), array('strict_variables' => true));
8484
$environment->addExtension(new TranslationExtension(new StubTranslator()));
85-
$environment->addExtension($this->extension);
85+
$environment->addExtension(new FormExtension());
8686
$environment->setCharset('ISO-8859-1');
8787

88-
$this->extension->initRuntime($environment);
88+
$rendererEngine = new TwigRendererEngine(array(
89+
'bootstrap_3_layout.html.twig',
90+
'custom_widgets.html.twig',
91+
), $environment);
92+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
93+
$this->registerTwigRuntimeLoader($environment, $this->renderer);
8994

9095
$view = $this->factory
9196
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')

Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Form\FormRenderer;
2020
use Symfony\Component\Form\FormView;
2121
use Symfony\Component\Form\Tests\AbstractBootstrap4HorizontalLayoutTest;
22+
use Twig\Environment;
2223

2324
/**
2425
* Class providing test cases for the Bootstrap 4 Twig form theme.
@@ -44,7 +45,7 @@ protected function setUp()
4445
__DIR__.'/Fixtures/templates/form',
4546
));
4647

47-
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
48+
$environment = new Environment($loader, array('strict_variables' => true));
4849
$environment->addExtension(new TranslationExtension(new StubTranslator()));
4950
$environment->addExtension(new FormExtension());
5051

Tests/Extension/FormExtensionBootstrap4LayoutTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Form\FormRenderer;
2020
use Symfony\Component\Form\FormView;
2121
use Symfony\Component\Form\Tests\AbstractBootstrap4LayoutTest;
22+
use Twig\Environment;
2223

2324
/**
2425
* Class providing test cases for the Bootstrap 4 horizontal Twig form theme.
@@ -42,7 +43,7 @@ protected function setUp()
4243
__DIR__.'/Fixtures/templates/form',
4344
));
4445

45-
$environment = new \Twig_Environment($loader, array('strict_variables' => true));
46+
$environment = new Environment($loader, array('strict_variables' => true));
4647
$environment->addExtension(new TranslationExtension(new StubTranslator()));
4748
$environment->addExtension(new FormExtension());
4849

@@ -78,6 +79,36 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
7879
$this->assertSame('<form name="form" method="get" action="0">', $html);
7980
}
8081

82+
public function testMoneyWidgetInIso()
83+
{
84+
$environment = new Environment(new StubFilesystemLoader(array(
85+
__DIR__.'/../../Resources/views/Form',
86+
__DIR__.'/Fixtures/templates/form',
87+
)), array('strict_variables' => true));
88+
$environment->addExtension(new TranslationExtension(new StubTranslator()));
89+
$environment->addExtension(new FormExtension());
90+
$environment->setCharset('ISO-8859-1');
91+
92+
$rendererEngine = new TwigRendererEngine(array(
93+
'bootstrap_4_layout.html.twig',
94+
'custom_widgets.html.twig',
95+
), $environment);
96+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
97+
$this->registerTwigRuntimeLoader($environment, $this->renderer);
98+
99+
$view = $this->factory
100+
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
101+
->createView()
102+
;
103+
104+
$this->assertSame(<<<'HTML'
105+
<div class="input-group"><div class="input-group-prepend">
106+
<span class="input-group-text">&euro; </span>
107+
</div><input type="text" id="name" name="name" required="required" class="form-control" /></div>
108+
HTML
109+
, trim($this->renderWidget($view)));
110+
}
111+
81112
protected function renderForm(FormView $view, array $vars = array())
82113
{
83114
return (string) $this->renderer->renderBlock($view, 'form', $vars);

Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,15 @@ public function testMoneyWidgetInIso()
172172
__DIR__.'/Fixtures/templates/form',
173173
)), array('strict_variables' => true));
174174
$environment->addExtension(new TranslationExtension(new StubTranslator()));
175-
$environment->addExtension($this->extension);
175+
$environment->addExtension(new FormExtension());
176176
$environment->setCharset('ISO-8859-1');
177177

178-
$this->extension->initRuntime($environment);
178+
$rendererEngine = new TwigRendererEngine(array(
179+
'form_div_layout.html.twig',
180+
'custom_widgets.html.twig',
181+
), $environment);
182+
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
183+
$this->registerTwigRuntimeLoader($environment, $this->renderer);
179184

180185
$view = $this->factory
181186
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')

0 commit comments

Comments
 (0)