Laravel删除表格 [英] Laravel Delete Forms

查看:85
本文介绍了Laravel删除表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据库查询中的大量数据构建一个HTML表,并且在表的最后一列中应显示一个编辑链接和一个删除链接.编辑链接可以正常工作,但是删除链接看起来并不像我想要的那样.我希望垃圾桶"图标的表单"按钮与编辑链接具有相同的表单,但是我不确定如何仅通过使其成为链接并位于表单内部就可以做到这一点.

I am building a HTML table with laravel of data from my database query and in the last column of the table it should be displaying an edit link and a delete link. The edit link works correctly however the delete link does not look the way I'm wanting it to. I'm wanting the Form button of the trash like icon to be in the same form as the edit link but I'm not sure how I can do that with making it just a link and inside of the form.

现在如何:

<td class="center">
    <a data-original-title="Edit" href="" data-toggle="tooltip" title="" class="tooltips"><i class="fa fa-pencil"></i></a>
    {{ Form::open(['route' => ['manager.roster.destroy', $member->id], 'class' => 'inline']) }}
        {{ Form::hidden('_method', 'DELETE') }}
        {{ Form::button('<i class="fa fa-trash-o"></i>', ['type' => 'submit', 'class' => 'delete-row tooltips', 'data-original-title' => 'Delete', 'data-toggle' => 'tooltip']) }}
    {{ Form::close() }}            
</td>

我想怎么做:

<td class="center">
    <a data-original-title="Edit" href="" data-toggle="tooltip" title="" class="tooltips"><i class="fa fa-pencil"></i></a>
    {{ Form::open(['route' => ['manager.roster.destroy', $member->id], 'class' => 'inline']) }}
        {{ Form::hidden('_method', 'DELETE') }}
        <a data-original-title="Delete" href="" data-toggle="tooltip" title="" class="tooltips"><i class="fa fa-trash"></i></a>
    {{ Form::close() }}            
</td>

推荐答案

您实际上可以将表单用于删除按钮并使用自定义样式,这是一个有效的示例:

You can actually use a form for the delete button and use custom styling, here's a working example:

<form action="{{ route('yourmodels.destroy', $yourmodel->id) }}" method="POST">
 {{ method_field('DELETE') }}
 {{ csrf_field() }}
<button type='submit' style="   
    background: none;
    color: #9aa0ac;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    outline: inherit;" >
 <i class="fe fe-trash-2"></i></button>
</form>

这篇关于Laravel删除表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆