So, custom fields are actually handled by Joomla itself. The “System - Fields” plugin returns the jcfields
object which has all fields for the ticket in the correct display order. We then remove fields which must not be displayed (they are restricted to a language other than the current one, they are set to not display in the frontend, or they have ATS Private set but the user is not authorised to see private fields) without changing their order. Finally, we call Joomla's \Joomla\Component\Fields\Administrator\Helper\FieldsHelper::render()
method which converts the jcfields
object to HTML we can display.
Reading the code of Joomla's FieldsHelper I figured out the way fields group ordering works. It looked insane, so I asked my wife who is one of a handful of people with vast experience using custom fields without being a backend developer. I was right. The ordering of groups is insane.
It is defined by the fields order.
Let's say you have the following fields, to be displayed in this order:
- Field A belongs in Group II
- Field B belongs in Group II
- Field C belongs to no group
- Field D belongs in Group I
- Field E belongs in Group III
The groups order is:
- Group II
- (No Group)
- Group I
- Group III
The groups are sorted in the order fields belonging in them are encountered.
Even better? The actual group information (group ID, ordering information, …) is NOT part of the jcfields
object returned by the System - Fields plugin. Therefore, even if we wanted to somehow change Joomla's awkward behaviour using custom code we can't.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!