Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
同一页上的两个表单Laravel_Laravel - Fatal编程技术网

同一页上的两个表单Laravel

同一页上的两个表单Laravel,laravel,Laravel,我已经在同一页面上注册并使用电子邮件字段登录。如果我提交的注册论坛存在验证错误,则该版本也将显示在登录表单上 如何在登记和签名表上注明价值 <input id="email" class="" name="email" type="text" placeholder="Email"> @if ($errors->has('email')) <span class="invalid-feedback" role="a

我已经在同一页面上注册并使用电子邮件字段登录。如果我提交的注册论坛存在验证错误,则该版本也将显示在登录表单上

如何在登记和签名表上注明价值

<input id="email" class="" name="email" type="text" placeholder="Email">                         
@if ($errors->has('email'))
    <span class="invalid-feedback" role="alert">
        <strong>{{ $errors->first('email') }}</strong>
    </span>
@endif
我们应该做到这一点

您应该覆盖LoginController中的
sendFailedLoginResponse()
方法

/**
* Get the failed login response instance.
*
* @param  \Illuminate\Http\Request  $request
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Illuminate\Validation\ValidationException
*/
protected function sendFailedLoginResponse(Request $request)
{
    return back()
        ->withInput($request->only($this->username(), 'remember'))
        ->withErrors([
            $this->username() => [trans('auth.failed')],
        ], 'login');
}
。。。然后在刀刃上,你可能会有这样的东西:

@if($errors->login->has('email'))
    <span class="help-block">
        <strong>{{ $errors->login->first('email') }}</strong>
    </span>
@endif
。。。然后在你的刀刃上

@if($errors->register->has('email'))
    <span class="help-block">
        <strong>{{ $errors->register->first('email') }}</strong>
    </span>
@endif
@if($errors->register->has('email'))
{{$errors->register->first('email')}
@恩迪夫

你能连接你的控制器吗。@Mcfaith它被定向到RegisterController@Mozammil这会影响$errors->first('email')。因为我有其他使用$errors->first('email')的表单。我是否需要更改所有内容?这只会影响您的登录/注册刀片:)
/**
 * Handle a registration request for the application.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function register(Request $request)
{
    $validator = $this->validator($request->all());

    if ($validator->fails()) {
        return back()
            ->withErrors($validator, 'register');
    }

    event(new Registered($user = $this->create($request->all())));

    $this->guard()->login($user);

    return $this->registered($request, $user)
                    ?: redirect($this->redirectPath());
}
@if($errors->register->has('email'))
    <span class="help-block">
        <strong>{{ $errors->register->first('email') }}</strong>
    </span>
@endif