File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
plugins/system/opengraph/src Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1515use Joomla \CMS \Event \Model \PrepareFormEvent ;
1616use Joomla \CMS \Plugin \CMSPlugin ;
1717use Joomla \Event \SubscriberInterface ;
18- use Joomla \CMS \Form \Form ;
1918use Joomla \CMS \Document \HtmlDocument ;
20- use Joomla \CMS \Table \Table ;
2119use Joomla \Registry \Registry ;
2220use Joomla \CMS \Document \Document ;
2321use Joomla \CMS \Opengraph \OpengraphServiceInterface ;
2422use Joomla \CMS \Uri \Uri ;
2523use Exception ;
2624use Joomla \CMS \Component \ComponentHelper ;
27- use Joomla \CMS \Table \Content ;
28- use Joomla \Database \DatabaseInterface ;
2925use Joomla \CMS \Menu \MenuItem ;
3026use Joomla \Component \Fields \Administrator \Helper \FieldsHelper ;
3127use Joomla \Component \Content \Site \Model \ArticleModel ;
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments