mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 13:33:48 +00:00
use translatable strign helper to translate string
This commit is contained in:
@@ -16,6 +16,7 @@ use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
|
||||
|
||||
class CustomFieldType extends AbstractType
|
||||
@@ -25,8 +26,12 @@ class CustomFieldType extends AbstractType
|
||||
* @var CustomFieldProvider
|
||||
*/
|
||||
private $customFieldProvider;
|
||||
|
||||
private $culture = 'fr';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
@@ -34,11 +39,14 @@ class CustomFieldType extends AbstractType
|
||||
private $om;
|
||||
|
||||
|
||||
public function __construct(CustomFieldProvider $compiler,
|
||||
ObjectManager $om)
|
||||
{
|
||||
public function __construct(
|
||||
CustomFieldProvider $compiler,
|
||||
ObjectManager $om,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->customFieldProvider = $compiler;
|
||||
$this->om = $om;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
@@ -60,7 +68,9 @@ class CustomFieldType extends AbstractType
|
||||
if ($options['group_widget'] === 'entity') {
|
||||
$builder->add('customFieldsGroup', EntityType::class, array(
|
||||
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
|
||||
'property' => 'name['.$this->culture.']'
|
||||
'choice_label' => function($g) {
|
||||
return $this->translatableStringHelper->localize($g->getName());
|
||||
}
|
||||
));
|
||||
} elseif ($options['group_widget'] === 'hidden') {
|
||||
$builder->add('customFieldsGroup', HiddenType::class);
|
||||
|
Reference in New Issue
Block a user