'How to achieve dynamic labelFor in UI5
I have a form to edit a list.
<VBox items="{path: 'localModel>/items', templateshareable: false}">
<items>
<Label text="My label" required="true" labelFor="{localModel>id}" />
<Input required="true" />
</items>
</VBox>
How can I link the labels and the inputs together?
Since UI5 does not allow dynamic id, I can not use the localModel link in the attribute labelFor
.
Solution 1:[1]
Try to use a factory instead of a XML template. In the factory you can dynamically generate IDs and use them for both Controls, Label and Input
Solution 2:[2]
this.byId("myLabel").setLabelFor("input1");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | A.vH |
Solution 2 | York Chen |