我有一个关于在laravel中显示错误的问题。所以我希望错误显示在占位符中。我已经做到了,但是,还有另一个问题。当我打开页面时,我看不到占位符,所以用户无法获得姓名等的输入。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="{{asset('css/signup.css')}}">
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login</title>
</head>
<body>
<div class="container">
<div class="logo"></div>
<form action="{{url('/register')}}" method='post'>
{{csrf_field()}}
<input name='name' id='name'value='@if(!$errors->first("name")){{old("name")}}@endif' placeholder="{{$errors->first('name')}}">
<input name='surname' value='@if(!$errors->first("surname")){{old("surname")}}@endif' placeholder="{{$errors->first('surname')}}">
<input name='email' value='@if(!$errors->first("email")){{old("email")}}@endif' placeholder="{{$errors->first('email')}}">
<input name='age' value='@if(!$errors->first("age")){{old("age")}}@endif' placeholder="{{$errors->first('age')}}">
<input name='password' value='@if(!$errors->first("password")){{old("password")}}@endif' type='password' placeholder='{{$errors->first("password")}}'>
<input name='confirm' value='@if(!$errors->first("confirm")){{old("confirm")}}@endif' type='password' placeholder='{{$errors->first("confirm")}}'>
<button class='btn btn-danger'>Save</button>
</form>
</div>
</body>
</html>
</body>
</html>
更新
<input name='name' id='name'value='@if(!$errors->first("name")){{old("name")}}@endif' placeholder="{{$errors->first('name')}}">
至
<input name='name' id='name'value='@if(!$errors->first("name")){{old("name")}}@endif' placeholder="{{$errors->has('name') ? $errors->first('name') : 'Name' }}">
其他输入标签也以同样的方式更新。