dimanche 18 octobre 2015

Laravel's AuthController doesn't validate my fields properly

I am writing an application in Laravel 5.1. According to the documentation I can authenticate and validate my login forms using their AuthController.

The only field I want to validate is a code-input field.

<form method="POST">
    <div class="form-group">
        <label for="code-input">Code</label>
        <input type="text" name="code-input" class="form-control" id="code-input" placeholder="Type your code here">
    </div>
    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
    <button type="submit" class="btn btn-default">Submit</button>
</form>

However, whenever I set my validation method in the AuthController to check only that field and submit an empty form I get an error that the email field is required and the password field is required. I mean, what?

protected function validator(array $data)
{
    return Validator::make($data, [
        'code-input' => 'required|max:255'
    ]);
}

Error message

My routes are also working correctly:

Route::get('/', 'Auth\AuthController@getLogin');
Route::post('/', 'Auth\AuthController@postLogin');
Route::get('/logout', 'Auth\AuthController@getLogout');

Does anybody know what is going on?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire