Skip to content

[Fix] 0047057 UI: Select field must not have more than one selected option#11009

Merged
thibsy merged 2 commits intoILIAS-eLearning:release_11from
fhelfer:ui/mantis/47057
Feb 25, 2026
Merged

[Fix] 0047057 UI: Select field must not have more than one selected option#11009
thibsy merged 2 commits intoILIAS-eLearning:release_11from
fhelfer:ui/mantis/47057

Conversation

@fhelfer
Copy link
Contributor

@fhelfer fhelfer commented Jan 30, 2026

When the select value was 0 (e.g. DataTable action dropdown), both the
placeholder option and the option with value "0" got selected="selected"
because PHP treats 0 as falsy. Use explicit empty check (value === null
|| value === '') for placeholder selection and clear SELECTED for
non-matching options so only one option is ever selected.

Problem

  • HTML-Validator: "The 'select' element cannot have more than one selected 'option' descendant unless the 'multiple' attribute is specified."
  • Trat z. B. bei DataTable-Aktions-Dropdown mit Wert 0 ("some action") auf: Platzhalter "Bitte auswählen" und Option value="0" hatten beide selected.

Lösung

  • Leerer Wert explizit prüfen: $value_is_empty = ($value === null || $value === '') statt !$value.
  • Platzhalter nur bei echt leerem Wert als selected markieren.
  • In der Options-Schleife SELECTED nur für die passende Option setzen, sonst leer.

Error: The “select” element cannot have more than one selected “option” descendant unless the “multiple” attribute is specified.
https://mantis.ilias.de/view.php?id=47057

@fhelfer fhelfer added bugfix kitchen sink php Pull requests that update Php code labels Jan 30, 2026
@Annett7811 Annett7811 added the accessibility Pull requests that propose A11Y changes. label Feb 6, 2026
@Annett7811 Annett7811 self-requested a review February 13, 2026 10:45
Copy link

@Annett7811 Annett7811 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!

From an accessibility perspective, this looks good. Thank you very much for your work.

Best regards,

Annett

Copy link
Contributor

@oliversamoila oliversamoila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello together,
Thank you very much for your contribution, @fhelfer. Thanks you for your review, @Annett7811. I agree and don't see these issues anymore.
I'm forwarding this to @thibsy for code review. He may contact you with change requests or incorporate the changes directly (That includes cherry picking too.)

Kind regards,
@oliversamoila (as UI coordinator)

Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fhelfer,

Thx a lot for your contribution to the UI framework!

Please implement the following changes:

  • Ternary: please replace this ternary operation with a dedicated if statement/block. We generally try to avoid ternary, because it decreases readability. While reading your code, I just had to double check that you do not set the selected-attribute all the time.
  • $value_is_empty: please a) reuse the new variable and negate it, and b) remove the ternary operation here as well.

Sorry for the nitpicks.

Kind regards,
@thibsy (as UI coordinator)

@fhelfer fhelfer requested a review from thibsy February 23, 2026 07:57
Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fhelfer,

Thx a lot for implementing the requested changes. This was a lot easier to review now =). Changes LGTM now.

Kind regards,
@thibsy (as UI coordinator)

@thibsy thibsy merged commit ea09def into ILIAS-eLearning:release_11 Feb 25, 2026
5 checks passed
thibsy pushed a commit that referenced this pull request Feb 25, 2026
thibsy pushed a commit that referenced this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Pull requests that propose A11Y changes. bugfix kitchen sink php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants