Due to a request by a community member, this thread is now also
available on http://stackoverflow.com/questions/42502268/oojs-ui-label-
data-mechanism-in-oo-ui-comboboxinputwidget
--
Robert

On Fr, 2017-02-24 at 08:04 +0000, Robert Vogel wrote:
> 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.MenuOpti
> onWidget-cfg-data
> 
> --
> Robert
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to