Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit42d54b7

Browse files
mpiotxabbuh
authored andcommitted
Add help_attr
1 parent557f85d commit42d54b7

File tree

16 files changed

+142
-8
lines changed

16 files changed

+142
-8
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@
177177

178178
{%blockform_help -%}
179179
{%-ifhelpis notempty -%}
180-
<spanid="{{id }}_help"class="help-block">
180+
{%-sethelp_attr=help_attr|merge({class: (help_attr.class|default('') ~' help-block')|trim}) -%}
181+
182+
<spanid="{{id }}_help" {%forattrname,attrvalueinhelp_attr %} {{attrname }}="{{attrvalue }}"{%endfor %}>
181183
{%-iftranslation_domainissame as(false) -%}
182184
{{-help -}}
183185
{%-else -%}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@
297297

298298
{%blockform_help -%}
299299
{%-ifhelpis notempty -%}
300-
<smallid="{{id }}_help"class="form-text text-muted">
300+
{%-sethelp_attr=help_attr|merge({class: (help_attr.class|default('') ~' form-text text-muted')|trim}) -%}
301+
302+
<smallid="{{id }}_help" {%forattrname,attrvalueinhelp_attr %} {{attrname }}="{{attrvalue }}"{%endfor %}>
301303
{%-iftranslation_domainissame as(false) -%}
302304
{{-help -}}
303305
{%-else -%}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@
291291

292292
{%blockform_help -%}
293293
{%-ifhelpis notempty -%}
294-
<pid="{{id }}_help"class="help-text">
294+
{%-sethelp_attr=help_attr|merge({class: (help_attr.class|default('') ~' help-text')|trim}) -%}
295+
296+
<pid="{{id }}_help" {%forattrname,attrvalueinhelp_attr %} {{attrname }}="{{attrvalue }}"{%endfor %}>
295297
{%-iftranslation_domainissame as(false) -%}
296298
{{-help -}}
297299
{%-else -%}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ public function testHelp()
120120
);
121121
}
122122

123+
publicfunctiontestHelpAttr()
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
publicfunctiontestErrors()
124144
{
125145
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\TextType');

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ public function testHelp()
177177
);
178178
}
179179

180+
publicfunctiontestHelpAttr()
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
publicfunctiontestErrors()
181201
{
182202
$form =$this->factory->createNamed('name', TextType::class);

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

Lines 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+
publicfunctiontestHelpAttr()
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
protectedfunctionrenderForm(FormView$view,array$vars =array())
194214
{
195215
return (string)$this->renderer->renderBlock($view,'form',$vars);

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

Lines 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+
publicfunctiontestHelpAttr()
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
protectedfunctionrenderForm(FormView$view,array$vars =array())
80100
{
81101
return (string)$this->renderer->renderBlock($view,'form',$vars);

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

Lines 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": {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?phpif (!empty($help)):?>
2-
<p id="<?phpecho$view->escape($id);?>_help" class="help-text"><?phpecho$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="<?phpecho$view->escape($id);?>_help"<?phpecho''.$view['form']->block($form,'attributes',array('attr' =>$help_attr));?>><?phpecho$view->escape(false !==$translation_domain ?$view['translator']->trans($help,array(),$translation_domain) :$help);?></p>
34
<?phpendif;?>

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

Lines 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+
publicfunctiontestHelpAttr()
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
protectedfunctionrenderForm(FormView$view,array$vars =array())
97117
{
98118
return (string)$this->engine->get('form')->form($view,$vars);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp