@extends('layouts.app')
@section('content')
<div class="row">
<div style="float:left;" class="col-md-8">
<h3>Currency</h3>
</div>
<div style="float:right;" class="col-md-4">
<a href="/currency/create" class="btn btn-dark btn-sm ml-3" style="float: right"><i class="fa fa-edit" style="color:white;"></i>Add New</a>
<input type="text" id="search" name="search" placeholder="search" class="form-control-sm col-md-8 ml-1" style="float:right;"><br><br>
</div>
</div>
@if(count($currencies) > 0 )
<table class="table table-striped table-sm" >
<thead>
<tr><th scope="col">ID</th><th scope="col">Currency</th><th scope="col">Country</th><th scope="col" colspan="2" style="text-align:right">Actions</th></tr>
</thead>
@foreach($currencies as $currency)
<tr><td scope="row">{{$currency->id}}</td>
<td>{{$currency->title}}</td>
<td>{{$currency->country}}</td>
{!!Form::open(['action'=>['CurrencyController@destroy', $currency->id], 'method'=>'POST'])!!}
{{Form::hidden('_method','DELETE')}}
@csrf
<td><button type="submit" class="btn btn-danger btn-sm" style="float:right"><i class="fa fa-remove" style="color:white;"></i>Delete</button>
<a href="/currency/{{$currency->id}}/edit" class="btn btn-primary btn-sm" style="float:right" ><i class="fa fa-edit" style="color:white;"></i>Edit</a></td></tr>
{!!Form::close() !!}
@endforeach
</table>
{{$currencies->links()}}
@else
<p> No Data Available </p>
@endif
@endsection
大家好,删除表单未在此代码中提交,我尝试了很多事情,但无法确定问题所在。请帮我解决一下这个。
答案 0 :(得分:0)
在我看来,您的html错误,您打开,关闭表单并将 for df in df_orginal:
NOW I AM STUCK
放在@csrf
标记之外,而其中的“提交”按钮位于其中
尝试在td
标签内移动表单定义,例如:
td
答案 1 :(得分:0)
尝试将实际form
标记中的方法更改为DELETE吗?默认情况下,如果您在路由中使用的是route::resource
之类的东西,它将自动将DELETE方法分配给该路由,而不是POST。
我可以看到您仍然在隐藏元素中指定了delete方法,但是值得一试。
{!!Form::open(['action'=>['CurrencyController@destroy', $currency->id], 'method'=>'POST'])!!}
如果不确定,请在终端的项目根目录中运行php artisan route:list
,它将为您提供应用程序的路由和方法的完整列表。