8000 [TwigBridge][Form] Added missing help messages in form themes · symfony/symfony@5374d4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5374d4f

Browse files
committed
[TwigBridge][Form] Added missing help messages in form themes
1 parent 8855082 commit 5374d4f

7 files changed

+103
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ col-sm-10
6464
<div class="{{ block('form_label_class') }}"></div>{#--#}
6565
<div class="{{ block('form_group_class') }}">
6666
{{- form_widget(form) -}}
67+
{{- form_help(form) -}}
6768
{{- form_errors(form) -}}
6869
</div>{#--#}
6970
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,15 @@
148148
{% block checkbox_row -%}
149149
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
150150
{{- form_widget(form) -}}
151+
{{- form_help(form) -}}
151152
{{- form_errors(form) -}}
152153
</div>
153154
{%- endblock checkbox_row %}
154155

155156
{% block radio_row -%}
156157
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' form-group' ~ (not valid ? ' has-error'))|trim})} %}{{ block('attributes') }}{% endwith %}>
157158
{{- form_widget(form) -}}
159+
{{- form_help(form) -}}
158160
{{- form_errors(form) -}}
159161
</div>
160162
{%- endblock radio_row %}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@
311311
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>
312312
<div class="large-12 columns{% if not valid %} error{% endif %}">
313313
{{ form_widget(form) }}
314+
{{- form_help(form) -}}
314315
{{ form_errors(form) }}
315316
</div>
316317
</div>
@@ -320,6 +321,7 @@
320321
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>
321322
<div class="large-12 columns{% if not valid %} error{% endif %}">
322323
{{ form_widget(form) }}
324+
{{- form_help(form) -}}
323325
{{ form_errors(form) }}
324326
</div>
325327
</div>

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,23 @@ public function testCheckboxRow()
163163

164164
$this->assertMatchesXpath($html, '/div[@class="form-group"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2);
165165
}
166+
167+
public function testCheckboxRowWithHelp()
168+
{
169+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
170+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
171+
172+
$this->assertMatchesXpath($html,
173+
'/div
174+
[@class="form-group"]
175+
[
176+
./div[@class="col-sm-2" or @class="col-sm-10"]
177+
/following-sibling::div[@class="col-sm-2" or @class="col-sm-10"]
178+
[
179+
./span[text() = "[trans]really helpful text[/trans]"]
180+
]
181+
]
182+
'
183+
);
184+
}
166185
}

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,21 @@ public function testCheckboxWithValue()
333333
);
334334
}
335335

336+
public function testCheckboxRowWithHelp()
337+
{
338+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
339+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
340+
341+
$this->assertMatchesXpath($html,
342+
'/div
343+
[@class="form-group"]
344+
[
345+
./span[text() = "[trans]really helpful text[/trans]"]
346+
]
347+
'
348+
);
349+
}
350+
336351
public function testSingleChoice()
337352
{
338353
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', '&a', [
@@ -2277,6 +2292,21 @@ public function testRadioWithValue()
22772292
);
22782293
}
22792294

2295+
public function testRadioRowWithHelp()
2296+
{
2297+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false);
2298+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
2299+
2300+
$this->assertMatchesXpath($html,
2301+
'/div
2302+
[@class="form-group"]
2303+
[
2304+
./span[text() = "[trans]really helpful text[/trans]"]
2305+
]
2306+
'
2307+
);
2308+
}
2309+
22802310
public function testRange()
22812311
{
22822312
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RangeType', 42, ['attr' => ['min' => 5]]);

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,25 @@ public function testCheckboxRowWithHelp()
231231
./small[text() = "[trans]really helpful text[/trans]"]
232232
]
233233
]
234+
'
235+
);
236+
}
237+
238+
public function testRadioRowWithHelp()
239+
{
240+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false);
241+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
242+
243+
$this->assertMatchesXpath($html,
244+
'/div
245+
[@class="form-group row"]
246+
[
247+
./div[@class="col-sm-2" or @class="col-sm-10"]
248+
/following-sibling::div[@class="col-sm-2" or @class="col-sm-10"]
249+
[
250+
./small[text() = "[trans]really helpful text[/trans]"]
251+
]
252+
]
234253
'
235254
);
236255
}

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,21 @@ public function testCheckboxWithValue()
422422
);
423423
}
424424

425+
public function testCheckboxRowWithHelp()
426+
{
427+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
428+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
429+
430+
$this->assertMatchesXpath($html,
431+
'/div
432+
[@class="form-group"]
433+
[
434+
./small[text() = "[trans]really helpful text[/trans]"]
435+
]
436+
'
437+
);
438+
}
439+
425440
public function testSingleChoiceExpanded()
426441
{
427442
$form = $this->factory->createNamed('name', ChoiceType::class, '&a', [
@@ -1027,6 +1042,21 @@ public function testRadioWithValue()
10271042
);
10281043
}
10291044

1045+
public function testRadioRowWithHelp()
1046+
{
1047+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\RadioType', false);
1048+
$html = $this->renderRow($form->createView(), ['label' => 'foo', 'help' => 'really helpful text']);
1049+
1050+
$this->assertMatchesXpath($html,
1051+
'/div
1052+
[@class="form-group"]
1053+
[
1054+
./small[text() = "[trans]really helpful text[/trans]"]
1055+
]
1056+
'
1057+
);
1058+
}
1059+
10301060
public function testButtonAttributeNameRepeatedIfTrue()
10311061
{
10321062
$form = $this->factory->createNamed('button', ButtonType::class, null, [

0 commit comments

Comments
 (0)
0