mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
user: refine display of location name (as usual, service injection does not work)
This commit is contained in:
parent
480e02af01
commit
593817f12e
@ -3,6 +3,7 @@
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
// use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -10,13 +11,27 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class UserCurrentLocationType extends AbstractType
|
||||
{
|
||||
|
||||
// private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
// /**
|
||||
// * @param TranslatableStringHelper $translatableStringHelper
|
||||
// */
|
||||
// public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
// {
|
||||
// $this->translatableStringHelper = $translatableStringHelper;
|
||||
// }
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('currentLocation', EntityType::class, [
|
||||
'class' => Location::class,
|
||||
'choice_label' => function (Location $entity) {
|
||||
return $entity->getName();
|
||||
return $entity->getName() ?
|
||||
$entity->getName() :
|
||||
//$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()); //TODO does not work
|
||||
$entity->getLocationType()->getTitle()['fr'];
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
@ -141,5 +141,9 @@ services:
|
||||
autowire: true
|
||||
|
||||
Chill\MainBundle\Form\Type\LocationFormType:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\MainBundle\Form\Type\UserCurrentLocationType:
|
||||
autowire: true
|
||||
autoconfigure: true
|
Loading…
x
Reference in New Issue
Block a user