WIP create new picker for accompanying period works

This commit is contained in:
2025-02-24 12:34:32 +01:00
parent 81ef64a246
commit 5d31ce96c1
3 changed files with 30 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Form;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Form\Type\PickAccompanyingPeriodWorkDynamicType;
use Chill\PersonBundle\Form\Type\PickLinkedAccompanyingPeriodWorkType;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -30,9 +31,10 @@ class FindAccompanyingPeriodWorkType extends AbstractType
$suggestedAcpw = $this->repository->findByAccompanyingPeriod($accompanyingPeriod);
$builder
->add('acpw', PickAccompanyingPeriodWorkDynamicType::class, [
->add('acpw', PickLinkedAccompanyingPeriodWorkType::class, [
'label' => 'Accompanying period work',
'suggested' => $suggestedAcpw
'suggested' => $suggestedAcpw,
'multiple' => false,
])
->add('direction', HiddenType::class, [
'data' => 'starting',

View File

@@ -12,14 +12,9 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface;
class PickAccompanyingPeriodWorkDynamicType extends AbstractType
class PickLinkedAccompanyingPeriodWorkType extends AbstractType
{
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addViewTransformer(new EntityToJsonTransformer($this->denormalizer, $this->serializer, $options['multiple'], 'person'));
}
public function __construct(private readonly NormalizerInterface $normalizer) {}
public function buildView(FormView $view, FormInterface $form, array $options)
{
@@ -30,8 +25,8 @@ class PickAccompanyingPeriodWorkDynamicType extends AbstractType
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
$view->vars['submit_on_adding_new_entity'] = false;
foreach ($options['suggested'] as $person) {
$view->vars['suggested'][] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']);
foreach ($options['suggested'] as $suggestion) {
$view->vars['suggested'][] = $this->normalizer->normalize($suggestion, 'json', ['groups' => 'read']);
}
}
@@ -50,7 +45,7 @@ class PickAccompanyingPeriodWorkDynamicType extends AbstractType
public function getBlockPrefix()
{
return 'pick_entity_dynamic';
return 'pick_linked_entities';
}
}