我有一个表单,我想在其中创建一个将打开另一个表单的模式。在我的示例中,我有一个考试,需要添加多个问题。这是我尝试执行的操作,但是问题是我在模型中调用的表单会取代整个表单。
这是我的观点……我只包含触发模式的按钮中的代码
<button type="button"
class="btn btn-primary btn-sm"
data-toggle="modal"
data-target="#addNew">
Add Questions
</button>
<!-- Modal -->
<div class="modal fade" id="addNew" tabindex="-1" role="dialog" aria-labelledby="addNewLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="addNewLabel">Add New Question</h4>
</div>
<form action= "{{route('examQuestion.create')}}" method="POST">
{{csrf_field()}}
<div class="modal-body">
@include('admin.exam_questions.create')
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Add Question</button>
</div>
</div>
</div>
</div>
@stop
@section('javascript')
@parent
<script>
$('#addNew').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever')
var modal = $(this)
modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body input').val(recipient)
})
</script>