我跟隨Dayle Rees的Laravel教程,嘗試構建一個簡單的註冊頁面。驗證方法validateConfirm不存在(Laravel)
如果我提交帶有驗證錯誤的註冊表單,頁面會重新載入並顯示驗證錯誤。然而,當我在正確值的鍵並提交,我碰到下面的錯誤 -
BadMethodCallException
Method [validateConfirm] does not exist.
這是我register.blade.php -
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<h1>Registration form</h1>
{{ Form::open(array('url' => '/registration')) }}
{{-- Username field. ------------------------}}
{{ Form::label('username', 'Username') }}
{{ Form::text('username') }}
{{ $errors->first('username', '<span class="error">:message</span>') }}
<br/>
{{-- Email address field. -------------------}}
{{ Form::label('email', 'Email address') }}
{{ Form::email('email') }}
{{ $errors->first('email', '<span class="error">:message</span>') }}
<br/>
{{-- Password field. ------------------------}}
{{ Form::label('password', 'Password') }}
{{ Form::password('password') }}
{{ $errors->first('password', '<span class="error">:message</span>') }}
<br/>
{{-- Password confirmation field. -----------}}
{{ Form::label('password_confirmation', 'Password confirmation') }}
{{ Form::password('password_confirmation') }}
<br/>
{{-- Form submit button. --------------------}}
{{ Form::submit('Register') }}
{{ Form::close() }}
</body>
</html>
這是我的routes.php文件[注意:這個問題消失,如果我刪除的規則密碼]
Route::get('/', function()
{
return View::make('register');
});
Route::post('/registration', function()
{
// Fetch all request data.
$data = Input::all();
// Build the validation constraint set.
$rules = array(
'username' => 'required|min:3|max:32',
'email' => 'required|email',
'password' => 'required|confirm|min:3'
);
// Create a new validator instance.
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
// Normally we would do something with the data.
return 'Data was saved.';
}
return Redirect::to('/')->withErrors($validator);
});
我試圖做密碼提示的東西,我的錯誤表示方法[validatePassword]不存在。我不知道我在哪裏做錯了。 – Eenvincible