- if edit
  - select_values = field.values.collect(&:reverse)
  - selected ||= wf.value(field.name)
  = select_tag(field.name, options_for_select(select_values, selected), drop_down_options(field, url))

  :javascript
    dialogFieldRefresh.initializeDialogSelectPicker('#{field.name}', '#{field.id}', '#{selected}', '#{url}');

- else
  = h(field.values.detect { |k, _v| k == wf.value(field.name) }.try(:last) || wf.value(field.name))

- if field.dynamic
  - if field.auto_refresh
    :javascript
      dialogFieldRefresh.listenForAutoRefreshMessages("#{field.id}", function() {
        var selectedValue = $('select[name="#{field.name}"]').val();
        dialogFieldRefresh.refreshDropDownList("#{field.name}", "#{field.id}", selectedValue);
      });

  - if field.show_refresh_button?
    = button_tag(_('Refresh'), :id => "refresh-dynamic-field-#{field.id}", :class => "btn btn-default")

  :javascript
    $('#refresh-dynamic-field-#{field.id}').click(function() {
      var selectedValue = $('select[name="#{field.name}"]').val();
      dialogFieldRefresh.refreshDropDownList("#{field.name}", "#{field.id}", selectedValue);
      dialogFieldRefresh.triggerAutoRefresh("#{field.id}", "#{field.trigger_auto_refresh}");
    });

- if edit
  - select_values = field.values.collect(&:reverse)
  - selected ||= wf.value(field.name)
  = select_tag(field.name, options_for_select(select_values, selected), drop_down_options(field, url))

  :javascript
    dialogFieldRefresh.initializeDialogSelectPicker('#{field.name}', '#{field.id}', '#{selected}', '#{url}');

- else
  = h(field.values.detect { |k, _v| [k, k.to_s].include?(wf.value(field.name)) }.try(:last) || wf.value(field.name))

- if field.dynamic
  - if field.auto_refresh
    :javascript
      dialogFieldRefresh.listenForAutoRefreshMessages("#{field.id}", function() {
        var selectedValue = $('select[name="#{field.name}"]').val();
        dialogFieldRefresh.refreshDropDownList("#{field.name}", "#{field.id}", selectedValue);
      });

  - if field.show_refresh_button?
    = button_tag(_('Refresh'), :id => "refresh-dynamic-field-#{field.id}", :class => "btn btn-default")

  :javascript
    $('#refresh-dynamic-field-#{field.id}').click(function() {
      var selectedValue = $('select[name="#{field.name}"]').val();
      dialogFieldRefresh.refreshDropDownList("#{field.name}", "#{field.id}", selectedValue);
      dialogFieldRefresh.triggerAutoRefresh("#{field.id}", "#{field.trigger_auto_refresh}");
    });

Fix value of dynamic dropdown list in prov. request details screen
Fix value of dynamic dropdown list in prov. request details screen

https://bugzilla.redhat.com/show_bug.cgi?id=1336015
