I have a template that loads a form. I have tried to use a loop to load all the items from the form but it doesn’t work. I’m thinking it’s something ridiculous I’m missing because it will load the items individually. Can anyone see what I’m missing! ? I am putting both the individual loaded items with the for loop beneath. Again it will individually load without a problem but the loop won’t work!?
template:
<form method="POST" action="{% url 'pt-search' %}" id="search_form">
{% csrf_token %}
<div class="form-section form-floating mb-3">
<div class="form-group mb-3">
<input type="text" class="form-control" id="search_fn" name="search" placeholder="First Name">{{ searchform.first_name }}
</div>
<div class="form-group mb-3">
<input type="text" class="form-control" id="search_ln" name="search" placeholder="Last Name">{{ searchform.last_name }}
</div>
<div class="form-group mb-3">
<input type="date" class="form-control" id="search_dob" name="search" placeholder="Date of Birth">{{ searchform.dob }}
</div>
<div class="form-group mb-3">
<input type="number" class="form-control" id="search_ssn" name="search" placeholder="SSN">{{ searchform.ssn }}
</div>
<div class="form-group mb-3">
<input type="number" class="form-control" id="search_mrn" name="search" placeholder="MRN">{{ searchform.mrn }}
</div>
{% for item in searchform %}
<div class="form-group mb-3">
<div class="form-label">{{ item.label }}:</div>
<div class="form-item">{{ item }}</div>
<div class="form-errors">{{ item.errors }}</div>
</div>
{% endfor %}
</div>
</form>