如何添加模态


How to add modal?

这是我在view.php文件中的链接,我想在单击添加播放器按钮时以模式显示我的表单。我该怎么做?我在模板中使用引导程序。

 <a data-toggle="modal" data-target="#myModal_login" class="btn btn-primary"  href="backend/players/player">Add Player</a>

insertPlayer.php这是我的插入表单,我想用模态显示我的插入表格。

    <div class="modal fade" id="myModal_login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <table  class="form-horizontal">
                        <tr  class="form-group"><td>First Name</td><td><?php echo form_input($fname) ?></td></td></tr>
                        <tr class="form-group" ><td>Last Name</td><td><?php echo form_input($lname) ?></td></tr>
                        <tr class="form-group"><td>Address</td><td><?php echo form_textarea($address) ?></td></tr>
</table>
</div>

试试下面的代码,它正在工作…:)

<a class="btn btn-primary" data-toggle="modal" href="#myModal">Add Player</a>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
         // Your form
         <form>
           First name:<br>
           <input type="text" name="firstname">
            <br>
           Last name:<br>
           <input type="text" name="lastname">
          </form> 
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

您可以将表单放入类似的模式div标记中

<div class="modal fade" id="myModal_login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <form>
   First name:<br>
   <input type="text" name="firstname">
     <br>
   Last name:<br>
   <input type="text" name="lastname">
</form> 
</div>

并称之为

<?php    
    include'insertPlayer.php';   
?> 
<a data-toggle="modal" data-target="#myModal_login" class="btn btn-primary"  href="backend/players/player">Add Player</a>