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