Skip to content

Commit 8613180

Browse files
[5.3] Show correct custom fields when creating article after filtering by multiple categories (joomla#45353)
Pull Request for Issue joomla#45303 This PR fixes a bug where creating a new article after filtering by multiple categories (e.g. "News" and "Events") incorrectly displays all custom fields from all those categories on the "Fields" tab.
1 parent fb59e60 commit 8613180

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

administrator/components/com_content/src/Model/ArticleModel.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,18 @@ protected function loadFormData()
587587
((isset($filters['published']) && $filters['published'] !== '') ? $filters['published'] : null)
588588
)
589589
);
590-
$data->set('catid', $app->getInput()->getInt('catid', (!empty($filters['category_id']) ? $filters['category_id'] : null)));
590+
591+
// If multiple categories are filtered, pick the first one to avoid loading all fields
592+
$filteredCategories = $filters['category_id'] ?? null;
593+
$selectedCatId = null;
594+
595+
if (\is_array($filteredCategories)) {
596+
$selectedCatId = (int) reset($filteredCategories);
597+
} elseif (!empty($filteredCategories)) {
598+
$selectedCatId = (int) $filteredCategories;
599+
}
600+
601+
$data->set('catid', $app->getInput()->getInt('catid', $selectedCatId));
591602

592603
if ($app->isClient('administrator')) {
593604
$data->set('language', $app->getInput()->getString('language', (!empty($filters['language']) ? $filters['language'] : null)));

0 commit comments

Comments
 (0)