how to set a default selection in a dynamically generated radio buttons



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];
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)

Any hints?


2 answers

This one is the BEST answer!

Bonjour Torea_142565,

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

$data.defaultValue = $data.listValues[ 0 ] ;


I hope this helps.


Submitted by torea_1402565 on Fri, 02/21/2020 - 20:13

Thank you for the solution!


Hello torea_1402565,

You need to put the default value in the formInput.

Exemple: {

P.S: "Refused" is the value of the Radio Button


Submitted by torea_1402565 on Wed, 01/15/2020 - 20:40

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?