Fixed method to display options in the current local and not en_US.

This commit is contained in:
Julien Chanséaume
2014-07-15 11:08:10 +02:00
committed by Julien Chanseaume
parent 1e0bb03804
commit 4aec6f4b3d

View File

@@ -13,6 +13,7 @@
namespace Thelia\Type; namespace Thelia\Type;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\TypeException; use Thelia\Exception\TypeException;
/** /**
@@ -67,8 +68,16 @@ class ModelValidIdType extends BaseType
{ {
$queryClass = $this->expectedModelActiveRecordQuery; $queryClass = $this->expectedModelActiveRecordQuery;
$query = $queryClass::create();
if (method_exists($query, "joinWithI18n")) {
if (null !== $locale = Translator::getInstance()->getLocale()) {
$query->joinWithI18n($locale);
}
}
$choices = array(); $choices = array();
foreach ($queryClass::create()->find() as $item) { foreach ($query->find() as $item) {
$choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId(); $choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId();
} }