0
votes

I would like have a way to show to user the error contextualized in a Switch (https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Switch.html) in the same way as I do with Input (https://sapui5.netweaver.ondemand.com/1.36.7/docs/api/symbols/sap.m.InputBase.html) by valueState and valueStateText properties.

enter image description here

2

2 Answers

0
votes

According to the documantation it is not intented to provide such a feature. Nevertheless, as I remember providing valueState and valueStateText activates specific css classes, and this can also be done for the switch control.

e.g. in the event handler of the change event: you can addStyleClass or removeStyleClass.

hope it helps...

0
votes

What you are looking for only works out of the box for controls that extend sap.m.InputBase which in turn inherits from sap.ui.core.Control. However, sap.m.Switch only extends sap.ui.core.Control. That's why sap.m.Switch does not support what you want out of the box.

You could implement your own custom Switch control that extends sap.m.InputBase to get what you want (recommended). Or you could write some JavaScript or CSS hacks to achieve what you want with the sap.m.Switch (not recommended).