diff --git a/machines/templates/machines/machine.html b/machines/templates/machines/machine.html index 4b308a11..d34dccb9 100644 --- a/machines/templates/machines/machine.html +++ b/machines/templates/machines/machine.html @@ -49,9 +49,17 @@ with this program; if not, write to the Free Software Foundation, Inc., {% if interfaceform %}

Interface

{% if i_bft_param %} + {% if 'machine' in interfaceform.fields %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' bft_param=i_bft_param %} + {% else %} {% bootstrap_form_typeahead interfaceform 'ipv4' bft_param=i_bft_param %} + {% endif %} {% else %} + {% if 'machine' in interfaceform.fields %} + {% bootstrap_form_typeahead interfaceform 'ipv4,machine' %} + {% else %} {% bootstrap_form_typeahead interfaceform 'ipv4' %} + {% endif %} {% endif %} {% endif %} {% if domainform %} diff --git a/machines/templatetags/bootstrap_form_typeahead.py b/machines/templatetags/bootstrap_form_typeahead.py index e076b52c..05dd3147 100644 --- a/machines/templatetags/bootstrap_form_typeahead.py +++ b/machines/templatetags/bootstrap_form_typeahead.py @@ -298,9 +298,9 @@ def reset_input( f_name ) : def default_choices( f_value ) : """ The JS script creating the variable choices_ """ - return '[ {objects} ]'.format( - objects = ', '.join( - [ '{{ key: {k}, value: "{k}" }}'.format( + return '[{objects}]'.format( + objects = ','.join( + [ '{{key:{k},value:"{v}"}}'.format( k = choice[0] if choice[0] != '' else '""', v = choice[1] ) for choice in f_value.choices ]