我正在关注有关 Laravel 的教程。
但是,我想将刀片模板 Form::open()
转换为 html/php 格式,以便于阅读和理解。
这是刀片模板:
{{ Form::open(['action'=> ['StudentController@destroy', $student->id], 'method'=>'POST']) }}
{{ method_field('DELETE') }}
{{ Form::submit('Delete',['class'=>'btn btn-danger']) }}
{{ Form::close() }}
我需要将刀片代码转换为 html/php 我尝试了多次,就像这样。但 失败了。
<form action="url('StudentController@destroy', $student->id)" method="POST">
<?php method_field('Delete'); ?>
<button class="btn btn-danger" type="submit">Delete</button>
</form>
有人知道正确的 html/php 表单吗?
原文由 Evan 发布,翻译遵循 CC BY-SA 4.0 许可协议
要调用控制器操作,您需要使用
url()->action(...)
(或action()
)简称。这在 手册 中也有描述