php - 路由没有指向 Laravel 中的控制器
问题描述
我正在 Laravel 中进行密码重置。
我有以下三个routes
Route::get('passwords/reset/{token?}','Auth\ResetPasswordController@showResetForm') ;
Route::post('passwords/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
Route::post('passwords/reset', 'Auth\ResetPasswordController@reset');
当我访问时,它正确password/reset
显示了以下内容form
<form action="{{ url('passwords/email') }}" method = 'post'>
<input type="email" name = 'email' class="form-control" id="exampleInputPassword1" placeholder="Enter Your Email Here" style = 'text-align:center'>
<button type='submit'>Send Link to Email to Reset Password</button>
</form>
但是当我点击按钮 Send Link to Email to Reset Password
时,URL
地址栏中的 不适合,password/emails
因为它应该根据action
表单中指定的位置去那里,我想去sendResetLinkEmail
的地方email
。
但是,URL
仍然与之前相同。
这就是我所拥有的ForgotPasswordController
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email', 'g-recaptcha-response' => 'required|captcha']);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email')
);
if ($response === Password::RESET_LINK_SENT) {
return back()->with('status', trans($response));
}
// If an error was returned by the password broker, we will get this message
// translated so we can notify a user of the problem. We'll redirect back
// to where the users came from so they can attempt this process again.
return back()->withErrors(
['email' => trans($response)]
);
}
我想去,sendResetLinkEmail
但是email
当我点击那个路由不是事件定位时button
,为什么会这样?
请帮忙谢谢!
解决方案
尝试动作功能
<form action="{{action(' Auth\ResetPasswordController@reset ') }}" method = 'post'>
<input type="email" name = 'email' class="form-control" id="exampleInputPassword1" placeholder="Enter Your Email Here" style = 'text-align:center'>
<button type='submit'>Send Link to Email to Reset Password</button>
</form>
推荐阅读
- javascript - 从 Cloud Function 写入 Firebase 实时数据库
- javascript - 当数据大于零时,如何更改数据的字体颜色?
- performance - 在大型阵列上测试 Dyalog 成语的时间
- c# - 如果 Jquery datepicker 在 onClose 期间尝试触发按钮单击,则无法设置 min\max 日期
- android - 片段中的 ExpandableListView 出错
- java - Intellij 无法正确导出
- node.js - 安装 Node.js windows 10 64bits 时出错
- pdf - 跨云端硬盘帐户将 Google 表格转换为 PDF
- asp.net - 而不是呈现页面 HTML 内容是在 MVC 中呈现
- google-apps-script - 有没有办法使用 Google Apps 脚本阅读 Outlook 电子邮件?