浏览代码

Merge branch '2.0' of https://github.com/lucciano/SonataAdminBundle into 2.0

Luciano Andrade 13 年之前
父节点
当前提交
331408e1f0

+ 17 - 0
Form/DataTransformer/BooleanTransformer.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Sonata\AdminBundle\Form\DataTransformer;
+
+use Symfony\Component\Form\DataTransformerInterface;
+use Sonata\AdminBundle\Form\Type\BooleanType;
+
+class BooleanTransformer implements DataTransformerInterface{
+    public function transform($boolFromPHP)
+    {
+        return ($boolFromPHP)?BooleanType::TYPE_YES:BooleanType::TYPE_NO;
+    }
+
+    public function reverseTransform($boolFromSonata){
+        return $boolFromSonata == BooleanType::TYPE_YES;
+    }
+}

+ 12 - 1
Form/Type/BooleanType.php

@@ -12,7 +12,9 @@
 namespace Sonata\AdminBundle\Form\Type;
 
 use Symfony\Component\Form\Extension\Core\Type\ChoiceType as FormChoiceType;
+use Symfony\Component\Form\FormBuilder;
 use Symfony\Component\Translation\TranslatorInterface;
+use Sonata\AdminBundle\Form\DataTransformer\BooleanTransformer;
 
 class BooleanType extends FormChoiceType
 {
@@ -30,6 +32,15 @@ class BooleanType extends FormChoiceType
         $this->translator = $translator;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    function buildForm(FormBuilder $builder, array $options)
+    {
+        parent::buildForm($builder, $options);
+        $builder->appendClientTransformer(new BooleanTransformer);
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -44,4 +55,4 @@ class BooleanType extends FormChoiceType
 
         return $options;
     }
-}
+}

+ 1 - 1
Resources/translations/SonataAdminBundle.es.xliff

@@ -184,7 +184,7 @@
             </trans-unit>
             <trans-unit id="message_batch_confirmation">
                 <source>message_batch_confirmation</source>
-                <target>¿Está seguro que quiere confirmar y ejecutar esta accion para todos los elementos seleccionados?</target>
+                <target>{0}¿Está seguro que quiere confirmar y ejecutar esta accion para todos los elementos seleccionados?|[1,+Inf[¿Está seguro que quiere confirmar y ejecutar esta accion para todos los %count% elementos seleccionados?</target>
             </trans-unit>
             <trans-unit id="btn_execute_batch_action">
                 <source>btn_execute_batch_action</source>