如何使用 laravel 中的 @included 在 bootstrap 模型中编辑表单
How to edit form in bootstrap model using @included in laravel
我在 laravel 中有编辑表单,在其他页面中效果很好,但我想在同一页面的 bootstrap 模态上编辑,点击任何分页中的编辑按钮 table.
是因为表单页面代码太长,我想找到保存代码的方法,我的想法是将表单代码复制到之前,然后将新页面作为 form.blade.php 我的问题是我需要如何或在哪里放置#include(reseller.form) 以确保它在编辑之前显示在 bootstrap 模态上!
分页中的编辑按钮
<button class="btn btn-danger btn-sm btn-mini" type="button" data-toggle="modal" data-target="#edits" data-debitur=""><i class="fas fa-times fa-fw"></i><b>Edit</b></button>
模态
<!-- Modal -->
<div class="modal fade" id="edits" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
form.blade.php
<div class="card-body">
<!-- Account ID -->
<div class="form-group row">
<label for="accountid" class="col-sm-2 col-form-label">Account Id:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller->accountid }}" name="accountid" id="accountid" placeholder="Account ID" >
<div>@error('accountid')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- Password -->
<div class="form-group row">
<label for="password" class="col-sm-2 col-form-label">Password:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller-> password }}" name="password" id="password" placeholder="Password">
<div>@error('password')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- Company Name -->
<div class="form-group row">
<label for="Company_name" class="col-sm-2 col-form-label">Company Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller-> companyname }}" name="companyname" id="companyname" placeholder="Company Name">
<div>@error('companyname')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- URL -->
还有jquery参与制作作品吗!请帮忙谢谢。
如果您使用的是布局模板,您可以使用@yield('modals') 在布局中定义一个部分,然后在您的实际视图中:
@section('modals')
@include('form')
@endsection
或者简单地在您的实际视图中执行 @include('form') 以显示模态,您可以通过 data-attributes 或使用 jQuery 事件来显示模态,就像您拥有的那样它在你的 html 很好,应该在按钮点击时显示模式,如果你想使用 jQuery 你可以这样做:
$('#form').modal('toggle');
或
$('#form').modal('show');
我在 laravel 中有编辑表单,在其他页面中效果很好,但我想在同一页面的 bootstrap 模态上编辑,点击任何分页中的编辑按钮 table.
是因为表单页面代码太长,我想找到保存代码的方法,我的想法是将表单代码复制到之前,然后将新页面作为 form.blade.php 我的问题是我需要如何或在哪里放置#include(reseller.form) 以确保它在编辑之前显示在 bootstrap 模态上!
分页中的编辑按钮
<button class="btn btn-danger btn-sm btn-mini" type="button" data-toggle="modal" data-target="#edits" data-debitur=""><i class="fas fa-times fa-fw"></i><b>Edit</b></button>
模态
<!-- Modal -->
<div class="modal fade" id="edits" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
form.blade.php
<div class="card-body">
<!-- Account ID -->
<div class="form-group row">
<label for="accountid" class="col-sm-2 col-form-label">Account Id:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller->accountid }}" name="accountid" id="accountid" placeholder="Account ID" >
<div>@error('accountid')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- Password -->
<div class="form-group row">
<label for="password" class="col-sm-2 col-form-label">Password:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller-> password }}" name="password" id="password" placeholder="Password">
<div>@error('password')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- Company Name -->
<div class="form-group row">
<label for="Company_name" class="col-sm-2 col-form-label">Company Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" value="{{ $reseller-> companyname }}" name="companyname" id="companyname" placeholder="Company Name">
<div>@error('companyname')<p style="color:red; font-weight: bold;">{{$message}}</p>@enderror</div>
</div>
</div>
<!-- URL -->
还有jquery参与制作作品吗!请帮忙谢谢。
如果您使用的是布局模板,您可以使用@yield('modals') 在布局中定义一个部分,然后在您的实际视图中:
@section('modals')
@include('form')
@endsection
或者简单地在您的实际视图中执行 @include('form') 以显示模态,您可以通过 data-attributes 或使用 jQuery 事件来显示模态,就像您拥有的那样它在你的 html 很好,应该在按钮点击时显示模式,如果你想使用 jQuery 你可以这样做:
$('#form').modal('toggle');
或
$('#form').modal('show');