Wondering if anybody has ever come up with a solution to this problem; my research tells me not. A bit convoluted explanation but hopefully you can understand...
I have a component which has both site and administrator views. Both have ordering
so I can control the ordering of items returned in the list view for the frontend. Great, so "sports" view can list each individual "sport" in any order I set in the admin. Perfect.
In the single item "sport" view, data is returned to this view in the usual getItem() return $this->_item;
. Of course, this is the entire table row.
Now, my issue is that we need to re-order the columns on a per-item ("sport") basis.
As an example, the object returned by getItem() is as below. Note, organisations
and teams
are subforms of "sports", so appear in separate tabs in the Joomla admin "Edit" view.
Sport Id #1:
Joomla\CMS\Object\CMSObject Object ( [_errors:protected] => Array ( ) [id] => [ordering] => [state] => [checked_out] => [checked_out_time] => [created_by] => [modified_by] => [sportname] => [invented] => [founders] => [description] => [organisations] => [teams] )
This is great, but for Sport ID #2, we want to return this object with the subforms in different order, like so:
Joomla\CMS\Object\CMSObject Object ( [_errors:protected] => Array ( ) [id] => [ordering] => [state] => [checked_out] => [checked_out_time] => [created_by] => [modified_by] => [sportname] => [description] => [founders] => [invented] => [teams] => [organisations] )
I have looked at adding an "order" integer field to each subform and then using this in the view to render the objects, but these cannot be made unique between subforms, creating room for user error in setting subforms to have the same integer value.
Has anyone come across this scenario and what are my options here?
If you managed to understand that, then thanks!