php – 如何使用Laravel的旧输入重定向?
发布时间:2020-12-14 19:55:25 所属栏目:大数据 来源:网络整理
导读:我有一个登录模式.当用户登录失败认证时,我想重定向到这个模式: 错误消息 和旧输入. 调节器 // if Auth Fail return Redirect::to('/') -with('error','Username/Password Wrong') -withInput(Request::except('password')) -withErrors($validator); 形成
我有一个登录模式.当用户登录失败认证时,我想重定向到这个模式:
>错误消息 调节器 // if Auth Fail return Redirect::to('/') ->with('error','Username/Password Wrong') ->withInput(Request::except('password')) ->withErrors($validator); 形成 {!! Form::open(array('url' => '/','class' => 'login-form')) !!} <div class="form-group"> <label for="username">Username</label> <input type="text" class="form-control" id="username" name="username" placeholder="Enter Username" required> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required> </div> <button type="submit" class="btn btn-primary">Login</button> {!! Form::close() !!} 正如你可以看到作为我的图像的一部分,错误消息似乎显示,但是用户名的旧输入似乎没有填充. 有人可以纠正我吗
您可以访问最后一个输入:
$username = Request :: old(‘username’); 正如@Arian Acosta所指出的,你可以简单地做 < input type =“text”... value =“{{old('username')}}”...> 如docs所述,它在刀片视图中更加方便. 控制器有几种可能性: 代替 做: a)Input :: flash(); 要么: b)Input :: flashExcept(‘password’); 并重定向到视图: a) – > withInput(Input :: except(‘password’)); RESP.有: b) – & withInput(); docs about Old Input进一步阅读… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |