How to set default value for dynamic dropdownlist?


Hi All,
I want to dynamic set default value for a drop-down-list element.

I only know this way to set default value, but after summit the dialog is ''.

dialog_hash['']="default value"
$evm.object['values'] = dialog_hash

I tired this but doesn’t work

$evm.object['default_value'] = { "default" => "value"}
$evm.object['defaults'] = { "default" => "value"}


Hi @MilkBotttle I use this snippet:

values_hash = {} #Your hash of values

list_values = {
     'sort_by'       => :value,
     'sort_order'    => :descending,
     'data_type'     => :integer,
     'required'      => true,
     'values'        => values_hash,
     'default_value' => default,
     'default'       => default

  list_values.each do |key, value| 
     $evm.object[key] = value

The “default” is a “value” of your drop down. If you have values_hash[‘21’] = ‘vm_id_21’ you should set default = 21 to display ‘vm_id_21’ as default.