我在 laravel 中有一个表格和表格,表格有一些用户价值,例如
上表我有用于选定复选框的按钮,例如delete
,copy details
等,所以我需要调用不同的控制方法。
只需使用 AJAX 和资源控制器。
然后,您可以对每个操作使用 REST 动词。
https://laravel.com/docs/5.4/controllers#resource-controllers
对的,这是可能的。HTML5 为 <button> 添加了一个 formaction 属性,允许它在单击时覆盖表单 url。您仍然需要每个操作一条路线。
<form method="post" action="/you-need-html5-error-page">
<button formaction="/delete"> delete </button>
<button formaction="/bedazzle> bedazzle </button>
<input type="checkbox" name="id" value="1">
<input type="checkbox" name="id" value="2">
</form>
formaction - 处理按钮提交的信息的程序的 URI。如果指定,它将覆盖按钮表单所有者的 action 属性。
来源:https ://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction