Skip to content

Commit 19fe1f7

Browse files
committed
fix : get custom fields for the respective category in dropdown
1 parent 1f95b29 commit 19fe1f7

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

plugins/system/opengraph/src/Extension/opengraph.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@
1515
use Joomla\CMS\Event\Model\PrepareFormEvent;
1616
use Joomla\CMS\Plugin\CMSPlugin;
1717
use Joomla\Event\SubscriberInterface;
18-
use Joomla\CMS\Form\Form;
1918
use Joomla\CMS\Document\HtmlDocument;
20-
use Joomla\CMS\Table\Table;
2119
use Joomla\Registry\Registry;
2220
use Joomla\CMS\Document\Document;
2321
use Joomla\CMS\Opengraph\OpengraphServiceInterface;
2422
use Joomla\CMS\Uri\Uri;
2523
use Exception;
2624
use Joomla\CMS\Component\ComponentHelper;
27-
use Joomla\CMS\Table\Content;
28-
use Joomla\Database\DatabaseInterface;
2925
use Joomla\CMS\Menu\MenuItem;
3026
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
3127
use Joomla\Component\Content\Site\Model\ArticleModel;

plugins/system/opengraph/src/Field/OpengraphField.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,18 @@ protected function getGroups()
9090

9191
$allowedTypes = $allowedFieldTypes[$fieldType] ?? [];
9292

93-
$customFields = FieldsHelper::getFields('com_content.article', null);
93+
94+
95+
$catId = (int) $this->form->getValue('id'); // editing existing cat
96+
if (!$catId) {
97+
// Creating a new category: use the chosen parent so assignments still work
98+
$catId = (int) $this->form->getValue('parent_id');
99+
}
100+
101+
// Dummy item with catid so FieldsService filters by assignment
102+
$scopeItem = $catId ? (object) ['catid' => $catId] : null;
103+
104+
$customFields = FieldsHelper::getFields('com_content.article', $scopeItem);
94105
$customOptions = [];
95106

96107
foreach ($customFields as $field) {

0 commit comments

Comments
 (0)