Преглед на файлове

Merge pull request #1048 from crisei/master

TranslatableChoiceType now translate expanded choices with the set catalogue
Thomas преди 12 години
родител
ревизия
4dab673ad9
променени са 2 файла, в които са добавени 4 реда и са изтрити 15 реда
  1. 2 15
      Form/Type/TranslatableChoiceType.php
  2. 2 0
      Resources/doc/reference/form_types.rst

+ 2 - 15
Form/Type/TranslatableChoiceType.php

@@ -47,21 +47,8 @@ class TranslatableChoiceType extends AbstractType
      * {@inheritDoc}
      */
     public function buildView(FormView $view, FormInterface $form, array $options)
-    {
-        // translate options before building form
-        foreach ($view->vars['choices'] as $choiceView) {
-            $choiceView->label = $this->translator->trans($choiceView->label, array(), $options['catalogue']);
-        }
-
-        // translate preferred options
-        foreach ($view->vars['preferred_choices'] as $choiceView) {
-            $choiceView->label = $this->translator->trans($choiceView->label, array(), $options['catalogue']);
-        }
-
-        // translate empty value
-        if (!empty($view->vars['empty_value'])) {
-            $view->vars['empty_value'] = $this->translator->trans($view->vars['empty_value'], array(), $options['catalogue']);
-        }
+    {       
+        $view->vars['translation_domain'] = $options['catalogue'];
     }
 
     /**

+ 2 - 0
Resources/doc/reference/form_types.rst

@@ -112,6 +112,8 @@ locked to 'yes' and 'no'.
 sonata_type_translatable_choice
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Deprecated: use ChoiceType with the translation_domain option instead.
+
 The translatable type is a specialized ``ChoiceType`` where the choices values 
 are translated with the Symfony Translator component.