I have a page made with UI designer which contains a radio buttons widget.
The available values are filled using a javascript expression retrieving all the groups the user belongs to :
function getGroupNames(data) {
var noms = [];
for( var i = 0; i < data.length; i++ ) {
noms[i] = data[i].group_id.name;
}
return noms;
}
return getGroupNames( $data.listeGroupes );
The selected value is a string variable.
When the page is displayed, no radio buttons is selected but I would like to select the first radio button by default.
I tried to set the value of the "selected value" variable at the end of the getGroupNames() function. It works but when I click on other radio button values, the black point in the button is not displayed anymore (although the values are correctly selected functionally)
I will write the answer here in english to make sure everyone can benefit from it.
In order to select by default the 1st button, you have to add a controler (Javascript variable) to control if the default value is empty. If it is empty, it will affect a default value automatically.
If ( ! $data.defaultValue && $data.listValues) {
// The default value here is empty and you retrieve the list of values, so you can affect a default value to your radio button list
Thank you for the hint but as the values are retrieved dynamically, how can i put the first value in the formInput as I don't know it at the beginning?
Bonitasoft empowers development teams with Bonita, the open-source and extensible platform to solve the most demanding process automation use cases. The Bonita platform accelerates delivery of complex applications with clear separation between capabilities for visual programming and for coding. Bonita integrates with existing solutions, orchestrates heterogeneous systems, and provides deep visibility into processes across the organization.