mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Select now store selections between forms.Partial: #362
This commit is contained in:
@@ -15,7 +15,8 @@ class AssetSearchForm(forms.Form):
|
||||
category = forms.ModelMultipleChoiceField(models.AssetCategory.objects.all(), required=False)
|
||||
status = forms.ModelMultipleChoiceField(models.AssetStatus.objects.all(), required=False)
|
||||
|
||||
class SupplierForm(forms.Form):
|
||||
|
||||
class SupplierForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = models.Supplier
|
||||
fields = '__all__'
|
||||
|
||||
@@ -22,26 +22,12 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.category.id_for_label }}" >Category</label>
|
||||
<select name="{{ form.category.name }}" id="{{ form.category.id_for_label }}" required class="form-control">
|
||||
{% for id, choice in form.category.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if object.category.id == id %}
|
||||
selected
|
||||
{% endif %}>
|
||||
{{ choice }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% render_field form.category|add_class:'form-control'%}
|
||||
</div>
|
||||
{% render_field form.is_cable|attr:'onchange=checkIfCableHidden()' %} <label for="{{ form.is_cable.id_for_label }}">Cable?</label>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.status.id_for_label }}" >Status</label>
|
||||
<select class="form-control" name="{{ form.status.name }}" id="{{ form.status.id_for_label }}" required>
|
||||
{% for id, choice in form.status.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if not object.status.id and choice == "Active" or object.status.id == id %}selected{% endif %}>{{ choice }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% render_field form.status|add_class:'form-control'%}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.serial_number.id_for_label }}">Serial Number</label>
|
||||
|
||||
@@ -8,25 +8,11 @@
|
||||
{% if create or edit or duplicate %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.plug.id_for_label }}">Plug</label>
|
||||
<select name="{{ form.plug.name }}" id="{{ form.plug.id_for_label }}" class="form-control">
|
||||
<option value="">
|
||||
{% for connector in connectors %}
|
||||
<option value="{{ connector.pk }}">
|
||||
{{ connector.description }}
|
||||
</option>
|
||||
{%endfor%}
|
||||
</select>
|
||||
{% render_field form.plug|add_class:'form-control'%}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.socket.id_for_label }}">Socket</label>
|
||||
<select name="{{ form.socket.name }}" id="{{ form.socket.id_for_label }}" class="form-control">
|
||||
<option value="">
|
||||
{% for connector in connectors %}
|
||||
<option value="{{ connector.pk }}">
|
||||
{{ connector.description }}
|
||||
</option>
|
||||
{%endfor%}
|
||||
</select>
|
||||
{% render_field form.socket|add_class:'form-control'%}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.length.id_for_label }}">Length</label>
|
||||
|
||||
@@ -8,15 +8,7 @@
|
||||
{% if create or edit or duplicate %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.purchased_from.id_for_label }}">Purchased From</label>
|
||||
<select class="form-control" name="{{ form.purchased_from.name }}" id="{{ form.purchased_from.id_for_label }}">
|
||||
{% for id, choice in form.purchased_from.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if object.purchased_from.id == id %}
|
||||
selected
|
||||
{% endif %}>
|
||||
{{ choice }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% render_field form.purchased_from|add_class:"form-control" %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user