Support

Akeeba Ticket System

#39473 Question: How are custom field groups ordered when viewing an existing ticket?

Posted in ‘Akeeba Ticket System for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Ticket System version
n/a

Latest post by nicholas on Friday, 15 September 2023 01:16 CDT

[email protected]

 Hello,

I have observed that when creating a new ticket, the custom field groups are ordered based on the "Sort Order". See attachment.

However, when viewing an existing ticket I do not understand how the field groups are ordered. It isn't alphabetical or by ID. See attachment 2.

Can you provide clarification and let me know if it is possible to change the sort order?

Thanks, 

nicholas
Akeeba Staff
Manager

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!

nicholas
Akeeba Staff
Manager

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!

[email protected]

Nicholas,

Well perhaps it's true that igonrance is bliss.

So it seems like my workaround is to order the fields so that they are sorted in the way I want the Field Groups ordered?

I will give this a try.

Thanks as always!

Eric

nicholas
Akeeba Staff
Manager

Correct. You need to sort the fields to affect the group order.

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!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!