OOUI's 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 typeobject
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". The code example in the official documentation shows this behavior [2]. 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-cfg-data
[2] https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.ComboBoxInputWidget
This question was originally posted on the wikitech-l
mailing list. You can find the thread here: http://markmail.org/message/fesegc3yljqcytzt