Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 42d54b7

Browse filesBrowse files
mpiotxabbuh
authored andcommitted
Add help_attr
1 parent 557f85d commit 42d54b7
Copy full SHA for 42d54b7

File tree

Expand file treeCollapse file tree

16 files changed

+142
-8
lines changed
Filter options
Expand file treeCollapse file tree

16 files changed

+142
-8
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@
177177

178178
{% block form_help -%}
179179
{%- if help is not empty -%}
180-
<span id="{{ id }}_help" class="help-block">
180+
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-block')|trim}) -%}
181+
182+
<span id="{{ id }}_help" {% for attrname, attrvalue in help_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
181183
{%- if translation_domain is same as(false) -%}
182184
{{- help -}}
183185
{%- else -%}

‎src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@
297297

298298
{% block form_help -%}
299299
{%- if help is not empty -%}
300-
<small id="{{ id }}_help" class="form-text text-muted">
300+
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' form-text text-muted')|trim}) -%}
301+
302+
<small id="{{ id }}_help" {% for attrname, attrvalue in help_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
301303
{%- if translation_domain is same as(false) -%}
302304
{{- help -}}
303305
{%- else -%}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@
291291

292292
{% block form_help -%}
293293
{%- if help is not empty -%}
294-
<p id="{{ id }}_help" class="help-text">
294+
{%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-text')|trim}) -%}
295+
296+
<p id="{{ id }}_help" {% for attrname, attrvalue in help_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
295297
{%- if translation_domain is same as(false) -%}
296298
{{- help -}}
297299
{%- else -%}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ public function testHelp()
120120
);
121121
}
122122

123+
public function testHelpAttr()
124+
{
125+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
126+
'help' => 'Help text test!',
127+
'help_attr' => array(
128+
'class' => 'class-test',
129+
),
130+
));
131+
$view = $form->createView();
132+
$html = $this->renderHelp($view);
133+
134+
$this->assertMatchesXpath($html,
135+
'/span
136+
[@id="name_help"]
137+
[@class="class-test help-block"]
138+
[.="[trans]Help text test![/trans]"]
139+
'
140+
);
141+
}
142+
123143
public function testErrors()
124144
{
125145
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ public function testHelp()
177177
);
178178
}
179179

180+
public function testHelpAttr()
181+
{
182+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
183+
'help' => 'Help text test!',
184+
'help_attr' => array(
185+
'class' => 'class-test',
186+
),
187+
));
188+
$view = $form->createView();
189+
$html = $this->renderHelp($view);
190+
191+
$this->assertMatchesXpath($html,
192+
'/small
193+
[@id="name_help"]
194+
[@class="class-test form-text text-muted"]
195+
[.="[trans]Help text test![/trans]"]
196+
'
197+
);
198+
}
199+
180200
public function testErrors()
181201
{
182202
$form = $this->factory->createNamed('name', TextType::class);

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,26 @@ public function testMoneyWidgetInIso()
190190
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
191191
}
192192

193+
public function testHelpAttr()
194+
{
195+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
196+
'help' => 'Help text test!',
197+
'help_attr' => array(
198+
'class' => 'class-test',
199+
),
200+
));
201+
$view = $form->createView();
202+
$html = $this->renderHelp($view);
203+
204+
$this->assertMatchesXpath($html,
205+
'/p
206+
[@id="name_help"]
207+
[@class="class-test help-text"]
208+
[.="[trans]Help text test![/trans]"]
209+
'
210+
);
211+
}
212+
193213
protected function renderForm(FormView $view, array $vars = array())
194214
{
195215
return (string) $this->renderer->renderBlock($view, 'form', $vars);

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
7676
$this->assertSame('<form name="form" method="get" action="0">', $html);
7777
}
7878

79+
public function testHelpAttr()
80+
{
81+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
82+
'help' => 'Help text test!',
83+
'help_attr' => array(
84+
'class' => 'class-test',
85+
),
86+
));
87+
$view = $form->createView();
88+
$html = $this->renderHelp($view);
89+
90+
$this->assertMatchesXpath($html,
91+
'/p
92+
[@id="name_help"]
93+
[@class="class-test help-text"]
94+
[.="[trans]Help text test![/trans]"]
95+
'
96+
);
97+
}
98+
7999
protected function renderForm(FormView $view, array $vars = array())
80100
{
81101
return (string) $this->renderer->renderBlock($view, 'form', $vars);

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/asset": "~3.4|~4.0",
2424
"symfony/dependency-injection": "~3.4|~4.0",
2525
"symfony/finder": "~3.4|~4.0",
26-
"symfony/form": "^4.1.5",
26+
"symfony/form": "^4.2",
2727
"symfony/http-foundation": "~3.4|~4.0",
2828
"symfony/http-kernel": "~3.4|~4.0",
2929
"symfony/polyfill-intl-icu": "~1.0",
@@ -42,7 +42,7 @@
4242
},
4343
"conflict": {
4444
"symfony/console": "<3.4",
45-
"symfony/form": "<4.1.2",
45+
"symfony/form": "<4.2",
4646
"symfony/translation": "<4.2"
4747
},
4848
"suggest": {
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php if (!empty($help)): ?>
2-
<p id="<?php echo $view->escape($id); ?>_help" class="help-text"><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($help, array(), $translation_domain) : $help); ?></p>
2+
<?php $help_attr['class'] = isset($help_attr['class']) ? trim($help_attr['class'].' help-text') : 'help-text'; ?>
3+
<p id="<?php echo $view->escape($id); ?>_help" <?php echo ' '.$view['form']->block($form, 'attributes', array('attr' => $help_attr)); ?>><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($help, array(), $translation_domain) : $help); ?></p>
34
<?php endif; ?>

‎src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ public function testMoneyWidgetInIso()
9393
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
9494
}
9595

96+
public function testHelpAttr()
97+
{
98+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
99+
'help' => 'Help text test!',
100+
'help_attr' => array(
101+
'class' => 'class-test',
102+
),
103+
));
104+
$view = $form->createView();
105+
$html = $this->renderHelp($view);
106+
107+
$this->assertMatchesXpath($html,
108+
'/p
109+
[@id="name_help"]
110+
[@class="class-test help-text"]
111+
[.="[trans]Help text test![/trans]"]
112+
'
113+
);
114+
}
115+
96116
protected function renderForm(FormView $view, array $vars = array())
97117
{
98118
return (string) $this->engine->get('form')->form($view, $vars);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.