Refactor type handling to contao-tags and add module tag filters
This commit is contained in:
+8
-10
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user