Laravel Delete Forms

2019-09-04 03:24发布

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.

How it is now:

<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>

How I want to somehow do it:

<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>

1条回答
劫难
2楼-- · 2019-09-04 03:56

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>
查看更多
登录 后发表回答