Add assetgroup form save action

pull/530/head
ibuler 8 years ago
parent 126d7fd62c
commit b8c10a0350

@ -21,7 +21,10 @@ class AssetForm(forms.ModelForm):
class AssetGroupForm(forms.ModelForm):
assets = forms.ModelMultipleChoiceField(queryset=Asset.objects.all())
assets = forms.ModelMultipleChoiceField(queryset=Asset.objects.all(),
widget=forms.SelectMultiple(attrs={
'class': 'select2',
'data-placeholder': _('Select assets')}))
def __init__(self, *args, **kwargs):
if kwargs.get('instance'):

@ -30,18 +30,18 @@
<form method="post" id="userForm" class="form-horizontal" action="" >
{% csrf_token %}
{{ form.name|bootstrap_horizontal }}
{# {{ form.assets|bootstrap_horizontal }}#}
{{ form.assets|bootstrap_horizontal }}
<div class="form-group">
<label for="users" class="col-sm-2 control-label">{% trans 'Asset' %}</label>
<div class="col-sm-9">
<select name="assets" id="assets" data-placeholder="{% trans 'Select asset' %}" class="select2 form-control m-b" multiple tabindex="2">
{% for asset in assets %}
<option value="{{ asset.id }}">{{ asset.ip }}:{{ asset.port }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label for="users" class="col-sm-2 control-label">{% trans 'Asset' %}</label>#}
{# <div class="col-sm-9">#}
{# <select name="assets" id="assets" data-placeholder="{% trans 'Select asset' %}" class="select2 form-control m-b" multiple tabindex="2">#}
{# {% for asset in assets %}#}
{# <option value="{{ asset.id }}">{{ asset.ip }}:{{ asset.port }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
{{ form.comment|bootstrap_horizontal }}

Loading…
Cancel
Save