Skip Navigation

[Resolved] Opening a Form with a button in a Modal with View/Block editor

This support ticket is created 2 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by danC-5 2 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2417003

Tell us what you are trying to do?
I'm cycling through several posts in a table on a page I'm having and I want to add a button to each item in the table to open the form I've made in a modal to edit the information from the front end. I've been trying to read through the documentation you have about adding a form to a layout and I don't think it's the same thing to have it recur for each item.

#2417381

Hi,

Thank you for contacting us and I'd be happy to assist.

From your website's code, it seems that it is loading the Bootstrap 4 library, which also includes the support for modals:
hidden link

In the loop of your view, you can show the edit form inside the modal window, using this HTML structure:


<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Modal-[wpv-post-id]">
  Edit this post
</button>
              

<!-- Modal -->
<div class="modal fade" id="Modal-[wpv-post-id]" tabindex="-1" role="dialog" aria-labelledby="Modal-[wpv-post-id]" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Edit: [wpv-post-title]</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        [cred_form form='slug-of-the-edit-form']
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

Note: Please replace "slug-of-the-edit-form" with the actual slug/name of your edit form.

The first part of the code will show the button to open the popup for each result, while the second part will show the edit form for each result inside the modal.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2417667

My issue is resolved now. Thank you!