User tests: Successful: Unsuccessful:
Pull Request resolves #36544
Custom fields assigned to a specific category were incorrectly appearing on the new category form even when they had no relevance to the category being created.
Why this happened:
In FieldsHelper::prepareForm(), the variable $assignedCatids is resolved from $data->catid, $data->fieldscatid, or the form's catid value. For a new category form, none of these are available — a category does not belong to another category via a catid field the way an article does. So $assignedCatids resolves to 0.
When getFields() is then called with $data, the condition that populates filter.assigned_cat_ids:
if ($item && (isset($item->catid) || isset($item->fieldscatid))) {...is never entered, because neither catid nor fieldscatid is set on $data. This means filter.assigned_cat_ids stays as [] (empty), and the model query returns all fields for the context with no category filtering — including fields that are assigned to specific categories.
There is a guard in the code intended to handle this case:
if (!$assignedCatids && !empty($field->assigned_cat_ids) && $form->getField($field->name)) {
$form->setFieldAttribute($field->name, 'required', 'false');
}However, this guard never fires because $field->assigned_cat_ids is not populated on the field object returned by the model — it is a filter parameter, not a field property. So category-specific fields render unconditionally on the new category form, and if any of them are marked as required, the user is blocked from saving a new category unless they fill in a field that is irrelevant to the category being created.
The fix:
In prepareForm(), before the second call to getFields(), explicitly set $data->fieldscatid = 0 when no category context can be determined and neither catid nor fieldscatid is already set on $data:
if (!$assignedCatids && !isset($data->catid) && !isset($data->fieldscatid)) {
$data->fieldscatid = 0;
}This causes getFields() to enter the filtering condition and set filter.assigned_cat_ids to [0], which restricts the model query to return only fields with no category assignment — the correct behavior when no category context is known.
The custom Fields tab loads on the new category form and displays "Test category field" even though it is assigned specifically to "Test category with field". Because the field is marked as required, the new category cannot be saved unless the custom field is filled in, even though it has no relevance to the category being created. Switching the parent category has no effect on the displayed fields until after saving.
The new category form loads without the custom field that is assigned to "Test category with field". The Fields tab either does not appear or shows only fields that have no specific category assignment. The new category can be saved without being blocked by irrelevant required fields.
Please select:
<link><link>| Status | New | ⇒ | Pending |
| Category | ⇒ | Administration com_fields |
| Labels |
Added:
PR-5.4-dev
|
||
I have tested this item ✅ successfully on 571ed95
I have successfully tested this PR ;) Thanks @CSGoat0! tested during the Friday May 1st, 2026 PR Testing Session.
I have tested this item ✅ successfully on 571ed95
Done in PR test session
I have tested this item ✅ successfully on 571ed95
Done in PR test session
| Labels |
Added:
bug
|
||
| Status | Pending | ⇒ | Ready to Commit |
RTC
RTC
✅ Final test before merge using JBT
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-05-05 09:48:49 |
| Closed_By | ⇒ | muhme | |
| Labels |
Added:
RTC
|
||
Thank you very much @CSGoat0 for your first time contribution. Thanks to @exlemor and @ThomasFinnern for testing.
hi @muhme, thank you! I appreciate that.
I think this issue #29186 should also be closed with this pr.
I have a question; I've been navigating issues for a while. Some are already fixed, some are wrong and so on.
Where should I report that? is the community interested about invalid issues (in order to close them)?
hi @muhme, thank you! I appreciate that. I think this issue #29186 should also be closed with this pr.
I have a question; I've been navigating issues for a while. Some are already fixed, some are wrong and so on. Where should I report that? is the community interested about invalid issues (in order to close them)?
@CSGoat0 A good place would be the „PD Bug Squad“ channel on Mattermost: https://joomlacommunity.cloud.mattermost.com/main/channels/pd-bug-squad
I have tested this item ✅ successfully on 571ed95
I have successfully tested this PR ;) Thanks @CSGoat0! tested during the Friday May 1st, 2026 PR Testing Session.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47586.