mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +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\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);
|
||||
|
@ -12,6 +12,7 @@ services:
|
||||
arguments:
|
||||
- "@chill.custom_field.provider"
|
||||
- "@doctrine.orm.entity_manager"
|
||||
- '@chill.main.helper.translatable_string'
|
||||
tags:
|
||||
- { name: 'form.type', alias: 'custom_field_choice' }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user