/
Invisible option issue with multi-option fields [5.2.2-B2]

Invisible option issue with multi-option fields [5.2.2-B2]

Each database column could have associated formatter class, that allows transforming data before it is displayed to user. For example:

  • date fields store timestamp (integer) in the database, but display nicely formatted date
  • option fields store option ID(s) in the database, but display option titles to user

The multi-option fields have an issue with data display, when 3 (or more) options are selected and 1 (or more) options are no longer available for selection. In such case instead displaying non-existing options as IDs some of existing options are not displayed.

Here is how to reproduce:

  1. define a field with 3 options: "Option 6" (ID: 6), "Option 9" (ID: 9), "Option 2" (ID: 2)
  2. create database record with all from above options selected
  3. change field configuration and remove "Option 9" option
  4. in the grid / form label instead of seeing "Option 6, 9, Option 2" you'll be seeing "9, Option 2"

This happens, because "\kOptionsFormatter::Format" method attempts to sort selected options to appear in order of available options. Since some of selected options are no longer available they're assigned to the 1st option in the list and overwrite any other option in there.

Solution

When sorting options in the "\kOptionsFormatter::Format" method place non-available options at the beginning (or end).

Related Tasks

INP-1777 - Getting issue details... STATUS