feat: edit selected accommodation of bookings in draft

This commit is contained in:
Björn Fromme committed 2026-08-20 12:34:44 +02:00
1 parent c1f0cda479
commit 3db1850e4f
8 files changed
+554 -5

No files matched your search

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace App\Form\Admin\Groups;
use App\Entity\Groups\Accommodation;
use App\Entity\Groups\AccommodationBooking;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Corrects the Gruppenhaus of a draft that was created against the wrong one. It is its own
* form rather than a field on AccommodationBookingType because the service choices there are
* resolved server-side from the current accommodation — changing it has to rebuild the whole
* edit form, which is why this runs as a modal that redirects back to it.
*
* The field is unmapped, the way the service fields on the edit form are: swapping the house
* drops the booked services along with it, so the change goes through
* AccommodationBookingService::changeAccommodation() as one transition instead of being
* written onto the entity piecemeal by the form.
*
* @extends AbstractType<AccommodationBooking>
*/
class AccommodationBookingChangeAccommodationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('accommodation', EntityType::class, [
'class' => Accommodation::class,
'mapped' => false,
'choice_label' => 'name',
'label' => 'Gruppenhaus neu',
'data' => $options['current_accommodation'],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => AccommodationBooking::class,
// Only ever reached for an Entwurf, which is a scratch record the office fills in
// over time — the `edit` group would reject it over contact data this form does
// not even show.
'validation_groups' => ['Default'],
'current_accommodation' => null,
]);
$resolver->setAllowedTypes('current_accommodation', ['null', Accommodation::class]);
}
}