add('dateFrom', null, [ 'html5' => true, 'widget' => 'single_text', ]) ->add('dateTo', null, [ 'html5' => true, 'widget' => 'single_text', ]) ->add('moves', CollectionType::class, [ 'entry_type' => ExpenseReportMoveType::class, 'collection_name' => 'moves', 'prototype' => true, 'allow_add' => true, 'allow_delete' => true, 'row_attr' => [ 'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light', ], 'label_attr' => [ 'class' => 'font-weight-bold', ], 'attr' => [ 'class' => 'mb-3 row', ], ]) ->add('variousPayments', CollectionType::class, [ 'entry_type' => ExpenseReportVariousPaymentType::class, 'collection_name' => 'variousPayments', 'prototype' => true, 'allow_add' => true, 'allow_delete' => true, 'row_attr' => [ 'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light', ], 'label_attr' => [ 'class' => 'font-weight-bold', ], 'attr' => [ 'class' => 'mb-3 row', ], ]) ; if ($builder->getData()->getId()) { $builder ->add('newBills', CollectionType::class, [ 'entry_type' => ExpenseReportNewBillType::class, 'mapped' => false, 'label' => 'Nouvelles factures', 'collection_name' => 'newBills', 'prototype' => true, 'allow_add' => true, 'allow_delete' => true, 'row_attr' => [ 'class' => 'mb-3 pb-3 pl-3 pr-3 pt-1 bg-light', ], 'label_attr' => [ 'class' => 'font-weight-bold', ], 'attr' => [ 'class' => 'mb-3 row', ], ]) ; } if (count($builder->getData()->getBills())) { $builder ->add('deleteBills', ExpenseReportDeleteBillType::class, [ 'mapped' => false, 'label' => 'Factures à supprimer', 'bills' => $builder->getData()->getBills(), 'row_attr' => [ 'class' => 'mb-3 p-3 bg-light', ], 'label_attr' => [ 'class' => 'font-weight-bold', ], 'attr' => [ 'class' => 'row mb-3', ], ]) ; } if ($options['is_treasurer']) { $builder ->add('user', EntityType::class, [ 'required' => true, 'class' => User::class, 'label' => 'Personne', 'choice_value' => 'id', 'query_builder' => function (EntityRepository $repo) { return $repo->createQueryBuilder('u') ->orderBy('u.displayName', 'ASC') ; }, 'constraints' => [ new NotBlank(), ], ]) ->add('isRequestedPayment', CheckboxType::class, [ 'required' => false, ]) ->add('isPaid', CheckboxType::class, [ 'required' => false, ]) ->add('paidAt', null, [ 'required' => false, 'html5' => true, 'widget' => 'single_text', ]) ; } } public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => ExpenseReport::class, 'is_treasurer' => false, ]); } }