Laravel 删除按钮不起作用
Laravel delete button not working
我想知道是否有人可以查看此代码并告诉我为什么它不起作用。当我按下提交按钮时,它不会提交。
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
我将其提交给 PostController 的 destory 方法,其中路由定义为 'posts'。
路由文件
Route::group(['prefix' => 'admin'], function() {
Route::resource('posts', 'PostController');
});
改变
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
至
{!! Form::open([
'method' => 'DELETE',
'route' => ['admin.posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
在路由中遵循您的前缀。希望对你有帮助
我想知道是否有人可以查看此代码并告诉我为什么它不起作用。当我按下提交按钮时,它不会提交。
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
我将其提交给 PostController 的 destory 方法,其中路由定义为 'posts'。
路由文件
Route::group(['prefix' => 'admin'], function() {
Route::resource('posts', 'PostController');
});
改变
{!! Form::open([
'method' => 'DELETE',
'route' => ['posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
至
{!! Form::open([
'method' => 'DELETE',
'route' => ['admin.posts.destroy', $post->id],
'style' => 'display: inline'
]) !!}
{!! Form::submit('Delete this post?', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
在路由中遵循您的前缀。希望对你有帮助