我的Web应用程序使用CodeIgniter框架和Bootstrap 3.0,我试图在我的模态中显示一个表单。我希望labels
与input fields
位于同一行,但将form-horizontal
添加到form
或modal-body
似乎没有帮助。
以下代码段: -
<!-- Add Customer Modal -->
<div class="modal fade" id="addCustomer" 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-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Add Customer</h4>
</div>
<div class="modal-body">
<?php echo form_open('customer_data/add_customer', ['class'=>'form-horizontal']); ?>
<?php echo form_label('Name: ', 'name'); ?>
<?php echo form_input(['name'=>'name', 'id'=>'name', 'class'=>'form-control']); ?>
<?php echo form_label('Mobile: ', 'mobileNum'); ?>
<?php echo form_input(['name'=>'mobileNum', 'id'=>'mobileNum', 'class'=>'form-control']); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-warning">Add Customer</button>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
答案 0 :(得分:0)
我认为你错过了一些功能
<?php echo form_close(); ?>
或试试这个:
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addCustomer">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="addCustomer" 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-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<!--form horizontal-->
<?php echo form_open('customer_data/add_customer', array('class'=>'form-horizontal')); ?>
<?php echo form_label('Name: ', 'name'); ?>
<?php echo form_input(array('name'=>'name', 'id'=>'name', 'class'=>'form-control')); ?>
<?php echo form_label('Mobile: ', 'mobileNum'); ?>
<?php echo form_input(array('name'=>'mobileNum', 'id'=>'mobileNum', 'class'=>'form-control')); ?>
<?php echo form_close();?>
<!--end 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>