Refactor type handling to contao-tags and add module tag filters
This commit is contained in:
@@ -58,6 +58,7 @@ class OrganizationEditController extends AbstractFrontendModuleController
|
||||
}
|
||||
|
||||
$organization = $this->organizationRepository->findById($organizationId);
|
||||
$allowedOrganizationTagIds = array_values(array_unique(array_map('intval', StringUtil::deserialize($model->organizationTypeTags ?? null, true))));
|
||||
|
||||
if (null === $organization) {
|
||||
$template->set('error', 'Organisation nicht gefunden.');
|
||||
@@ -77,7 +78,7 @@ class OrganizationEditController extends AbstractFrontendModuleController
|
||||
'email' => (string) ($organization['email'] ?? ''),
|
||||
'website' => (string) ($organization['website'] ?? ''),
|
||||
'description' => (string) ($organization['description'] ?? ''),
|
||||
'type' => StringUtil::deserialize($organization['type'] ?? null, true),
|
||||
'tags' => $this->organizationRepository->getTagIdsForOrganization($organizationId),
|
||||
];
|
||||
|
||||
$currentLogoPath = null;
|
||||
@@ -90,13 +91,22 @@ class OrganizationEditController extends AbstractFrontendModuleController
|
||||
}
|
||||
}
|
||||
|
||||
$form = $this->createForm(OrganizationType::class, $formData);
|
||||
$form = $this->createForm(OrganizationType::class, $formData, [
|
||||
'tag_choices' => $this->organizationRepository->getTagChoicesForOrganizationType($allowedOrganizationTagIds),
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$submittedData = (array) $form->getData();
|
||||
|
||||
$this->organizationRepository->update($organizationId, $submittedData);
|
||||
$selectedTagIds = array_values(array_unique(array_map('intval', (array) ($submittedData['tags'] ?? []))));
|
||||
|
||||
if ([] !== $allowedOrganizationTagIds) {
|
||||
$selectedTagIds = array_values(array_intersect($selectedTagIds, $allowedOrganizationTagIds));
|
||||
}
|
||||
|
||||
$this->organizationRepository->assignTagsToOrganization($organizationId, $selectedTagIds);
|
||||
|
||||
$deleteLogo = '1' === (string) $request->request->get('remove_logo', '0');
|
||||
$uploadedLogo = $form->get('logoUpload')->getData();
|
||||
|
||||
Reference in New Issue
Block a user