Hi everybody!
I'm working on some OOJS-UI components for an extension and I've stumbled across
something:
The "OO.ui.ComboBoxInputWidget" allows to set an array of
"OO.ui.MenuOptionWidget" objects in its "menu.items" config field.
Such an item can have a "label" and a "data" field. The
"data" field can be of type "object" [1].
Now, if I use a "data" field of type "object" the value of the
"OO.ui.ComboBoxInputWidget" will be "[Object object]", as it tries to
cast the "data" value to a string when a user selects an option item.
So it looks like "OO.ui.ComboBoxInputWidget" allows only "data" of
type "string" in its options. Is that correct?
That would also mean that there is no "label/data" mechanism of the input field
itself. If I've got the following options
[
{ label: "Rot", data: "red" },
{ label: "Gelb", data: "yellow" },
{ label: "Grün", data: "green" }
]
and the user selects the option with label "Gelb" the input field shows
"yellow", not "Gelb". Did I miss something? Is it possible to show a
"label" to the user but retrieve the "data" (object) when calling
"getValue" on such a field?
[1]
https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.MenuOptionWidget-c…
--
Robert