diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
index 6c92dc8b6b..7405612a9b 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
@@ -98,6 +98,7 @@
{%- for child in form %}
{{- form_widget(child, {
parent_label_class: label_attr.class|default(''),
+ translation_domain: choice_translation_domain,
}) -}}
{% endfor -%}
@@ -106,6 +107,7 @@
{%- for child in form %}
{{- form_widget(child, {
parent_label_class: label_attr.class|default(''),
+ translation_domain: choice_translation_domain,
}) -}}
{% endfor -%}
@@ -169,7 +171,7 @@
{% endif %}
{% endif %}
{% endblock checkbox_radio_label %}
diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
index 6b315f4640..48a432e41a 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
@@ -46,7 +46,7 @@
{%- for child in form %}
{{- form_widget(child) -}}
- {{- form_label(child) -}}
+ {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}}
{% endfor -%}
{%- endblock choice_widget_expanded -%}
@@ -220,7 +220,7 @@
{% set label = name|humanize %}
{%- endif -%}
{%- endif -%}
-
+
{%- endif -%}
{%- endblock form_label -%}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php
index 64ae7dbc95..2c42687207 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_expanded.html.php
@@ -1,6 +1,6 @@
block($form, 'widget_container_attributes') ?>>
widget($child) ?>
- label($child) ?>
+ label($child, null, array('translation_domain' => $choice_translation_domain)) ?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php
index 27bba27c2b..7a51b2ce7b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_label.html.php
@@ -4,5 +4,5 @@
$name, '%id%' => $id))
: $view['form']->humanize($name); } ?>
-
+
diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
index da506025d9..44f08b4fc1 100644
--- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
@@ -231,6 +231,29 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
);
}
+ public function testSingleChoiceWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', '&a', array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
+ 'multiple' => false,
+ 'expanded' => false,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')),
+'/select
+ [@name="name"]
+ [@class="my&class form-control"]
+ [not(@required)]
+ [
+ ./option[@value="&a"][@selected="selected"][.="Choice&A"]
+ /following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
+ ]
+ [count(./option)=2]
+'
+ );
+ }
+
public function testSingleChoiceAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
@@ -629,6 +652,42 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
);
}
+ public function testSingleChoiceExpandedWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', '&a', array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
+ 'multiple' => false,
+ 'expanded' => true,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/div
+ [
+ ./div
+ [@class="radio"]
+ [
+ ./label
+ [.="Choice&A"]
+ [
+ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
+ ]
+ ]
+ /following-sibling::div
+ [@class="radio"]
+ [
+ ./label
+ [.="Choice&B"]
+ [
+ ./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
+ ]
+ ]
+ /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
+ ]
+'
+ );
+ }
+
public function testSingleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
@@ -792,6 +851,52 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
);
}
+ public function testMultipleChoiceExpandedWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
+ 'multiple' => true,
+ 'expanded' => true,
+ 'required' => true,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/div
+ [
+ ./div
+ [@class="checkbox"]
+ [
+ ./label
+ [.="Choice&A"]
+ [
+ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
+ ]
+ ]
+ /following-sibling::div
+ [@class="checkbox"]
+ [
+ ./label
+ [.="Choice&B"]
+ [
+ ./input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
+ ]
+ ]
+ /following-sibling::div
+ [@class="checkbox"]
+ [
+ ./label
+ [.="Choice&C"]
+ [
+ ./input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
+ ]
+ ]
+ /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
+ ]
+'
+ );
+ }
+
public function testMultipleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
index 8589f35904..e4b82063fa 100644
--- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -168,6 +168,20 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
);
}
+ public function testLabelWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'text', null, array(
+ 'translation_domain' => false,
+ ));
+
+ $this->assertMatchesXpath($this->renderLabel($form->createView()),
+'/label
+ [@for="name"]
+ [.="Name"]
+'
+ );
+ }
+
public function testLabelOnForm()
{
$form = $this->factory->createNamed('name', 'date');
@@ -513,6 +527,28 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
);
}
+ public function testSingleChoiceWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', '&a', array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
+ 'multiple' => false,
+ 'expanded' => false,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/select
+ [@name="name"]
+ [not(@required)]
+ [
+ ./option[@value="&a"][@selected="selected"][.="Choice&A"]
+ /following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
+ ]
+ [count(./option)=2]
+'
+ );
+ }
+
public function testSingleChoiceAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
@@ -889,6 +925,29 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
);
}
+ public function testSingleChoiceExpandedWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', '&a', array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
+ 'multiple' => false,
+ 'expanded' => true,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/div
+ [
+ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
+ /following-sibling::label[@for="name_0"][.="Choice&A"]
+ /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
+ /following-sibling::label[@for="name_1"][.="Choice&B"]
+ /following-sibling::input[@type="hidden"][@id="name__token"]
+ ]
+ [count(./input)=3]
+'
+ );
+ }
+
public function testSingleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', '&a', array(
@@ -986,6 +1045,32 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
);
}
+ public function testMultipleChoiceExpandedWithoutTranslation()
+ {
+ $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(
+ 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'),
+ 'multiple' => true,
+ 'expanded' => true,
+ 'required' => true,
+ 'choice_translation_domain' => false,
+ ));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/div
+ [
+ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
+ /following-sibling::label[@for="name_0"][.="Choice&A"]
+ /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
+ /following-sibling::label[@for="name_1"][.="Choice&B"]
+ /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
+ /following-sibling::label[@for="name_2"][.="Choice&C"]
+ /following-sibling::input[@type="hidden"][@id="name__token"]
+ ]
+ [count(./input)=4]
+'
+ );
+ }
+
public function testMultipleChoiceExpandedAttributes()
{
$form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array(