using modals for forms....

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

using modals for forms....

Alexander Joseph
I've tried every tutorial on how to use modals with forms in django and have basically got nowhere.

The latest one I tried is this one
https://dmorgan.info/posts/django-views-bootstrap-modals/

I seem to be running into the same problem with them though, which is I'm not sure where to put the code for the modal.

In my list view I have the button for the modal which looks like...
<button type="button" class="btn btn-secondary" href="{% url 'engineering:gaas_wafer_design_create' %}" data-toggle="modal" data-target="#form-modal">
  Add
</button>

But one of my problems is I'm not sure where to put the actual modal code and/or if I need to split up the modal code. I'm using class based views and this is going to be a form for a create view.

When I put the code for the modal shell in the list view as well (btw here is my modal shell) ...
<div class="modal fade" id="form-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Modal title</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span>
        </button>
      </div>
      <div id="form-modal-body" class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

obviously the modal pops up fine and displays the "..." in the body

But I have found no way in all the tutorials to even display the form in the modal, much less handle the ajax submitting of the form. Does anyone have a better tutorial or can give me direction?? Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d1230b14-6b34-4b9f-8712-43fa2721d938%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.