feat: filter destinations by common name

This commit is contained in:
Björn Fromme
2024-10-28 09:09:17 +01:00
parent 80cd9ca17f
commit f155b5ae52
4 changed files with 41 additions and 36 deletions
+14 -15
View File
@@ -18,7 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class AssignmentFilterType extends AbstractType
{
public function __construct(private readonly Security $security)
public function __construct(private readonly Security $security, private readonly array $destinations)
{
}
@@ -90,20 +90,20 @@ class AssignmentFilterType extends AbstractType
])
;
}
if (0 < count($options['hotels'])) {
$choices = [];
foreach ($options['hotels'] as $item) {
$choices[$item->getHotel()] = $item->getHotelCode();
}
$builder
->add('hotels', MultiselectType::class, [
'label' => 'Haus',
'required' => false,
'empty_label' => 'nicht filtern',
'choices' => $choices,
])
;
$hotelChoices = [];
$destinations = $this->destinations;
sort($destinations);
foreach ($destinations as $item) {
$hotelChoices[$item] = $item;
}
$builder
->add('hotels', MultiselectType::class, [
'label' => 'Haus/Destination',
'required' => false,
'empty_label' => 'nicht filtern',
'choices' => $hotelChoices,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
@@ -114,7 +114,6 @@ class AssignmentFilterType extends AbstractType
'min_date' => null,
'max_date' => null,
'job_profiles' => [],
'hotels' => [],
])
->setAllowedTypes('min_date', [\DateTimeImmutable::class, 'null'])
->setAllowedTypes('max_date', [\DateTimeImmutable::class, 'null'])