Hello everyone,
I have a modal form. After submitting this form, I want the bootstrap modal to remain in place and all fields to be readonly so that I cant change the fields but review them. How can I do that?
Thank you in advance.
home.html
<div class="modal fade bd-example-modal-xl" {% block modal-id %} id="addsampleModal" {% endblock modal-id %} tabindex="-1" aria-labelledby="addsampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header" {% block modal-style %} style="background-color: #add9ff;" {% endblock modal-style %}>
<h5 class="modal-title" id="addsampleModalLabel">
{% block modal-title %}
<i class="fa-solid fa-database"></i> Add Sample data
{% endblock modal-title %}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true"></span>
</button>
</div> <!-- end modal header -->
<form method="POST" {% block action %} action="/addsample_row" {% endblock action %} autocomplete="off">{% csrf_token %}
<div class="modal-body">
-----------------------(There are codes here)-----------------------
<div class="modal-footer">
<button type="submit" id="submit_disabled" class="btn btn-outline-dark">
{% block btn2-action %}
Add new sample
{% endblock btn2-action %}
</button>
{% block resetbutton-action %}
<button type="reset" class="btn btn-outline-warning" title="Reset">Clear form</button>
{% endblock resetbutton-action %}
</div> <!-- end modal footer -->
views.py
def addsample_row(request):
if request.method == "POST":
if request.POST.get('culture') \
and request.POST.get('index_sample') \
and request.POST.get('is_index_sample') \
and request.POST.get('status'):
sample = Samples()
sample.culture = request.POST.get('culture')
sample.index_sample = request.POST.get('index_sample')
sample.is_index_sample = request.POST.get('is_index_sample')
sample.status = request.POST.get('status')
sample.save()
messages.success(request, "New sample is added successfully!")
return HttpResponseRedirect("/")
else:
return render(request, 'addsample.html')