manavo / laravel-bootstrap-forms

ABANDONED - Using @stidges' code for bootstrap forms to create a composer package.

Home Page:http://blog.stidges.com/post/easy-bootstrap-forms-in-laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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);
            }

    }