Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form tag removing automatically from Bootstrap modal

In the default magento 1.9 version, I am facing a problem with modal popup.

It's working fine but the form tag is being automatically removed. When I view the page source, the form tag is there. I don't know what I'm doing wrong.

<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>
<div class="modal" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <form id="modalForm" name="modalForm" action="/test" method="post">
          <input type="text" name="text" />
        </form>
        Content for the dialog / modal goes here.
      </div>
      <div class="modal-footer">
        <a href="#" data-dismiss="modal" class="btn">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
      </div>
    </div>
  </div>
</div>

Fiddle demo

Any help?

like image 677
Supravat Mondal Avatar asked Jun 11 '15 13:06

Supravat Mondal


People also ask

How do I stop Bootstrap modal closing?

If you want to prevent boostrap modal from closing by those actions, you need to change the value of backdrop and keyboard configuration. The default value of backdrop and keyboard is set to true . You can change the configuration in HTML or Javascript directly.

How do you stop modal from closing when clicking outside HTML?

When the Button is clicked, the HTML DIV is referenced using jQuery and its modal function is called along with properties data-backdrop: "static" and data-keyboard: false which disables the closing of the Bootstrap Modal Popup when clicked outside.

How do you prevent Bootstrap 4 modal from closing when clicking outside?

On Options chapter, in the page you linked, you can see the backdrop option. Passing this option with value 'static' will prevent closing the modal.

How do I remove a field from Bootstrap modal?

Use the trigger() function on the form element.


1 Answers

I experienced this exact problem today (although I was using Spree rather than Magento). My mistake was placing the bootstrap modal html within an existing form element.

Chrome automatically removes form tags within an existing form element. See question here.

Moving your modal window to the bottom of the body tag may help.

like image 181
cdyer Avatar answered Oct 14 '22 02:10

cdyer