Skip to content

[5.3] Show correct custom fields when creating article after filtering by multiple categories#45353

Merged
richard67 merged 5 commits intojoomla:5.3-devfrom
AdarshSantoria:cat
Apr 20, 2025
Merged

[5.3] Show correct custom fields when creating article after filtering by multiple categories#45353
richard67 merged 5 commits intojoomla:5.3-devfrom
AdarshSantoria:cat

Conversation

@AdarshSantoria
Copy link
Contributor

Pull Request for Issue #45303

Summary of Changes

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.

Joomla previously used the catid filter directly from user state or input, which led to ambiguous behavior when multiple categories were selected. This fix:

  • Detects when category_id filter is an array
  • Selects the first selected category from the filtered list
  • Ensures only relevant custom fields are loaded for the selected category
  • Supports fallback logic for single-category filter or default category

This resolves #45303 and improves clarity and correctness of the custom field rendering in the admin UI.


Testing Instructions

  1. Create two categories: Events and News
  2. Create two custom fields:
    • events_title → assigned to Events
    • news_title → assigned to News
  3. Go to Content > Articles
  4. Apply category filter for both "Events" and "News"
  5. Click New Article
    • ✅ Only one custom field (events_title or news_title) should appear on the "Fields" tab
  6. Change category using dropdown
    • ✅ Custom fields update correctly

Actual result BEFORE applying this Pull Request

Screenshot (37)

  • When filtered by multiple categories and clicking "New", all fields from all selected categories are loaded.
  • Changing category does not reload the field list properly.

Expected result AFTER applying this Pull Request

Screenshot (36)

  • Only the first selected category’s custom fields are loaded initially
  • Changing category in the form correctly reloads the associated custom fields dynamically
  • Prevents confusion and clutter in the custom fields UI

Link to documentation

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on 56c2e62

Functionality works as described


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45353.

@JackJoeJack
Copy link

I also have tested this item ✅ successfully on 56c2e62

Functionality works as described

@QuyTon
Copy link
Contributor

QuyTon commented Apr 19, 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45353.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Apr 19, 2025
@richard67 richard67 added the bug label Apr 19, 2025
@richard67
Copy link
Member

I've just double-checked this PR and it works and seems not to break anything else.

@richard67 richard67 merged commit 8613180 into joomla:5.3-dev Apr 20, 2025
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Apr 20, 2025
@richard67
Copy link
Member

Thanks all (author and testers).

@richard67 richard67 added this to the Joomla! 5.3.1 milestone Apr 20, 2025
richard67 pushed a commit to richard67/joomla-cms that referenced this pull request Apr 23, 2025
…g 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a new article when filtering several categories, shows custom fields for all those categories

6 participants

Comments