Refactor type handling to contao-tags and add module tag filters

This commit is contained in:
Jürgen Mummert
2026-02-21 22:23:53 +01:00
parent a6440c74a2
commit f93ed0d0c6
18 changed files with 413 additions and 63 deletions
+8 -10
View File
@@ -39,7 +39,7 @@ class EventType extends AbstractType
])
->add('startDate', DateType::class, [
'label' => 'Startdatum',
'required' => false,
'required' => true,
'widget' => 'single_text',
'input' => 'string',
'html5' => false,
@@ -110,7 +110,7 @@ class EventType extends AbstractType
->add('location_id', ChoiceType::class, [
'label' => 'Veranstaltungsort',
'choices' => $options['location_choices'],
'required' => false,
'required' => true,
'choice_value' => static fn ($value) => null !== $value ? (string) $value : '',
'placeholder' => 'Bitte auswählen',
'attr' => [
@@ -118,17 +118,13 @@ class EventType extends AbstractType
'data-placeholder' => 'Veranstaltungsort suchen …',
],
])
->add('type', ChoiceType::class, [
'label' => 'Typ',
'choices' => [
'Unterkunft' => 'accommodation',
'Einkaufen' => 'shopping',
'Kultur' => 'culture',
],
->add('tags', ChoiceType::class, [
'label' => 'Typen',
'choices' => $options['tag_choices'],
'multiple' => true,
'required' => false,
'attr' => [
'class' => 'js-event-type-choice',
'class' => 'js-event-tags-choice',
'data-placeholder' => 'Typen suchen …',
],
])
@@ -191,6 +187,7 @@ class EventType extends AbstractType
$resolver->setDefaults([
'csrf_protection' => true,
'location_choices' => [],
'tag_choices' => [],
'organization_choices' => [],
'selected_organization_ids' => [],
'show_organization' => false,
@@ -198,6 +195,7 @@ class EventType extends AbstractType
]);
$resolver->setAllowedTypes('location_choices', 'array');
$resolver->setAllowedTypes('tag_choices', 'array');
$resolver->setAllowedTypes('organization_choices', 'array');
$resolver->setAllowedTypes('selected_organization_ids', 'array');
$resolver->setAllowedTypes('show_organization', 'bool');
+14 -8
View File
@@ -11,6 +11,7 @@ use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class OrganizationType extends AbstractType
{
@@ -27,17 +28,13 @@ class OrganizationType extends AbstractType
->add('email', EmailType::class, ['label' => 'E-Mail', 'required' => false])
->add('website', TextType::class, ['label' => 'Webseite', 'required' => false])
->add('description', TextareaType::class, ['label' => 'Beschreibung', 'required' => false])
->add('type', ChoiceType::class, [
'label' => 'Typ',
'choices' => [
'Unterkunft' => 'accommodation',
'Einkaufen' => 'shopping',
'Kultur' => 'culture',
],
->add('tags', ChoiceType::class, [
'label' => 'Typen',
'choices' => $options['tag_choices'],
'multiple' => true,
'required' => false,
'attr' => [
'class' => 'js-organization-type-choice',
'class' => 'js-organization-tags-choice',
'data-placeholder' => 'Typ auswählen …',
],
])
@@ -51,4 +48,13 @@ class OrganizationType extends AbstractType
],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'tag_choices' => [],
]);
$resolver->setAllowedTypes('tag_choices', 'array');
}
}