feat: multiselect field for filtering

This commit is contained in:
Björn Fromme
2024-07-15 18:25:14 +02:00
parent 1cb0227d1e
commit 7d84f321da
9 changed files with 151 additions and 31 deletions
+4 -4
View File
@@ -80,11 +80,11 @@ class AssignmentFilterType extends AbstractType
if (0 < count($options['job_profiles'])) {
$builder
->add('jobProfile', EntityType::class, [
->add('jobProfiles', MultiselectEntityType::class, [
'label' => 'Job-Profil',
'class' => JobProfile::class,
'required' => false,
'placeholder' => 'nicht filtern',
'empty_label' => 'nicht filtern',
'choice_label' => 'name',
'choices' => $options['job_profiles'],
])
@@ -96,10 +96,10 @@ class AssignmentFilterType extends AbstractType
$choices[$item->getHotel()] = $item->getHotelCode();
}
$builder
->add('hotel', ChoiceType::class, [
->add('hotels', MultiselectType::class, [
'label' => 'Haus',
'required' => false,
'placeholder' => 'nicht filtern',
'empty_label' => 'nicht filtern',
'choices' => $choices,
])
;
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Form;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MultiselectEntityType extends AbstractType
{
public function getParent(): string
{
return EntityType::class;
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['empty_label'] = $options['empty_label'];
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'multiple' => true,
'expanded' => true,
'empty_label' => null,
]);
}
public function getBlockPrefix(): string
{
return 'multiselect';
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MultiselectType extends AbstractType
{
public function getParent(): string
{
return ChoiceType::class;
}
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['empty_label'] = $options['empty_label'];
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'multiple' => true,
'expanded' => true,
'empty_label' => null,
]);
}
public function getBlockPrefix(): string
{
return 'multiselect';
}
}