Errors not working
opened this issue · comments
I am not able to see any validation errors.
Here is my controller :
public function getCreate()
{
return View::make('user.login');
}
public function postCreate()
{
$rules = array(
'username' => 'required|min:3'
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return View::make('user.login')->withErrors($validator);
}
}
The errors work when you redirect, and the errors are saved in the session.
To get them to work, you should just be able to change your code to this:
public function postCreate()
{
$rules = array(
'username' => 'required|min:3'
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
}