0
如何阻止自動提交表單?目前,下面所示的控制器功能(deleteAccount)會在加載頁面時立即執行,而只能在點擊按鈕時觸發。表單在頁面加載時自動提交
相關路線:
Route::resource("myaccount", "MyAccountController");
Route::get("myaccount", "[email protected]");
相關的控制器功能:
public function deleteAccount(){
$user = \Auth::user();
\Auth::logout();
$user->delete();
flash()->success("Account Deleted Successfully!");
return redirect("/");
}
相關的視圖代碼:
{{ Form::open(array('action' => '[email protected]')) }}
{{ method_field('get') }}
<button type="submit">Delete Account!</button>
{{ Form::close() }}