The FormEngine renderType `selectSingle` can display a selected icon
on the left side of the select field.
`\TYPO3\CMS\Backend\Form\Element\SelectSingleElement` decides to render
the selected item conditionally by looping over all select items and
checking each item for a configured icon and sets the `$hasIcons` flag,
which is later used to decide, if the icon display should be rendered
at all, or not.
Further, if no selected icon has been found the first icon of the first
item of the first group is currently used as fallback, when having an
icon.
Looking onto the current implementation, following issues are revealed:
* The decision to render the selected icon pane left of the select
field is soley made based on the last select item of last item
group and not if at least one select item has an icon or not.
* If a item is selected, but has no icon defined the defined icon
of the first item of the first group is used as fallback, which
is considerable wrong. The fallback is intended to use that item
only if no selection has been made.
* The `select icon` field wizard displays only the icons of items
with a existing item, leaving items without an item out.
The last issue requires a greater decision related to UX handling
of that component and is not considered with this change and left
for a later general overwork of the component.
That means, this change itself concentrates on the first two issues,
which are resolvable with a overseable effort. To accomplish this,
this change:
* Uses the whole item array to track the selected state instead of
the selected icon value to avoid a double meaning of empty string.
* Renders the selected icon pane left of the select field when at
least one select item has a icon defined accomplished by setting
the flag `$hasIcons` to true when an icon is found, but not to
`false` in the other case. On top, the check is moved into the
inner loop to check on each item of a group and not on the last
item of a group.
* Modifies the fallback handling to use the first item icon of the
first group only if no selected item is specified and no longer
in case a selected item has no icon set, which also displayed the
wrong item labels !!!.
That means, that for a selected without a icon no icon is displayed
left of the select field, but the box for the icon is there. This
matches the current behaviour, if the last item has an icon, but a
selected item which is not the last one is selected and has no icon.
The case with some items having icons and some not needs to be handled
in a dedicaded change and requires a general user-experience decision
how to deal with that, on the select field and the select icon wizard.