How to assign a selected value to a select widget
I am retrieving customers from an external DB and add them in a select widget then one is selected and the data is displayed in widgets on a form.
It works fine for inputs widgets and they easily display what I tell them but antother select widget that lists available titles (Dr., Monsieur, Madame) is not displaying the title value of the selected customer.
Even more, this select widget is stuck on the last value (Madame) in the list and doesn't allow me to choose any other.
I did a test an managed to successfully update a select widget with customer title after selection of a customer in a select widget.
You can download my example (created with version 7.4.1).
Note that I didn't use "Displayed key" and "Returned key" (didn't use a map) but simply "Available values" (a simple list). But it should also be fully functional if you are using "Displayed key" and "Returned key".
I also managed to successfully update the select widget with customer title after selection of a customer in the other select widget.
I finally was able to do it as I previously gave wrong value to the 'returned key' and 'value' propreties.
For this case, the available values for the title widget were hardcoded in a json variable following the pair "label":"value" format.
However, I have another case about devices and deviceGroups following quite a similar pattern as the one with the customer and its title.
When a List<data.model.deviceGroup> is used to populate the select (where deviceGroup is not organized following the "label":"value" pair) the behavior seems different.
The widget is correctly populated with retrieved deviceGroups but doesn't display the deviceGroup of the selected device
The "displayed key" is "name".
The "returned key" is empty and even if it is empty, it definitly does update the formInput.device.deviceGroup variable bound to the "value" property of the select widget but it doesnt display the deviceGroup of the selcted device.
The "available values" is bound to List<data.model.deviceGroup>.value wich returns a json array.
Here is a sample of how the List<data.model.deviceGroup>.value ends up and is passed to the widget.
"name": "Imagerie mobile"
Right that's it. It is a kind of identical pattern than with the customer and the customer's title.
But you can figure it out in the device task of the project that you allready downloaded from another thread.
the project can be found there: