+ let $aninput;
+ if (field.value_type.widget == 'select') {
+ $aninput = $("<select class='form-control'>");
+ $.each(field.value_type.options, function() {
+ $("<option>").text(this).appendTo($aninput);
+ })
+ } else {
+ $aninput = $("<input class='form-control'>");
+ if (field.value_type.autocomplete) {
+ let autoOptions = field.value_type.autocomplete;
+ $aninput.autocomplete(autoOptions).autocomplete('instance')._renderItem = function(ul, item) {
+ let t = item.label;
+ if (item.name) t += '<br><small><strong>' + item.name + '</strong></small>';
+ if (item.description) t += '<br><small><em>' + item.description + '</em></small>';
+ return $( "<li>" )
+ .append( "<div>" + t + "</div>" )
+ .appendTo( ul );
+ };
+ }
+ }