FIX [translations][types] remove redundant translator and change datetime field to date field

This commit is contained in:
Julie Lenaerts 2023-01-27 10:51:59 +01:00
parent 86b5f4dfac
commit f76c031ff3
2 changed files with 7 additions and 16 deletions

View File

@ -13,6 +13,7 @@ namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Form\Type\ChillDateTimeType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -20,20 +21,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class AbsenceType extends AbstractType
{
private TranslatorInterface $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('absenceStart', ChillDateTimeType::class, [
->add('absenceStart', ChillDateType::class, [
'required' => true,
'input' => 'datetime_immutable',
'label' => $this->translator->trans('absence.Absence start'),
'label' => 'absence.Absence start',
]);
}

View File

@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Form\Type\ChillDateTimeType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickCivilityType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityRepository;
@ -40,16 +41,12 @@ class UserType extends AbstractType
private TranslatableStringHelper $translatableStringHelper;
private TranslatorInterface $translator;
public function __construct(
TranslatableStringHelper $translatableStringHelper,
ParameterBagInterface $parameterBag,
TranslatorInterface $translator
ParameterBagInterface $parameterBag
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->parameterBag = $parameterBag;
$this->translator = $translator;
}
public function buildForm(FormBuilderInterface $builder, array $options)
@ -117,10 +114,10 @@ class UserType extends AbstractType
return $qb;
},
])
->add('absenceStart', ChillDateTimeType::class, [
->add('absenceStart', ChillDateType::class, [
'required' => false,
'input' => 'datetime_immutable',
'label' => $this->translator->trans('absence.Absence start'),
'label' => 'absence.Absence start',
]);
// @phpstan-ignore-next-line