From 4aec6f4b3d802e9d5d0fa5e6fea2e96c56ac3f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Chans=C3=A9aume?= Date: Tue, 15 Jul 2014 11:08:10 +0200 Subject: [PATCH] Fixed method to display options in the current local and not en_US. --- core/lib/Thelia/Type/ModelValidIdType.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Type/ModelValidIdType.php b/core/lib/Thelia/Type/ModelValidIdType.php index e3419fdd2..10185fe28 100644 --- a/core/lib/Thelia/Type/ModelValidIdType.php +++ b/core/lib/Thelia/Type/ModelValidIdType.php @@ -13,6 +13,7 @@ namespace Thelia\Type; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Thelia\Core\Translation\Translator; use Thelia\Exception\TypeException; /** @@ -67,8 +68,16 @@ class ModelValidIdType extends BaseType { $queryClass = $this->expectedModelActiveRecordQuery; + $query = $queryClass::create(); + + if (method_exists($query, "joinWithI18n")) { + if (null !== $locale = Translator::getInstance()->getLocale()) { + $query->joinWithI18n($locale); + } + } + $choices = array(); - foreach ($queryClass::create()->find() as $item) { + foreach ($query->find() as $item) { $choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId(); }