Geoff_S
Geoff_S

Reputation: 5107

Laravel will not route properly from form

on the URL user/password/change I have a form:

{!! Form::open(array('route' => 'password.recover')) !!}
    <div class="form-group">
        <label for="email">Email Address</label>
        <input type="email" class="form-control" name="email" id="email" value="{{ old('email') }}" />
    </div>
    <div class="form-group">
        <label for="password">New Password</label>
        <input type="password" class="form-control" name="password" id="password" />
    </div>
    <div class="form-group">
        <label for="password_confirmation">New Password (again)</label>
        <input type="password" class="form-control" name="password_confirmation" id="password_confirmation" />
    </div>
    <div class="form-group">
        <label for="password_confirmation">Verification Code (from text message)</label>
        <input type="text" class="form-control" name="verification_code" id="verification_code" />
    </div>
    <button type="submit" class="btn btn-primary btn-block">Reset Password</button>
{!! Form::close() !!}

That form is on the blade views/auth/reset.blade.php

The form action is calling this route in my routes.auth file:

Route::post('password/recover', 'Auth\AuthController@reset')
->name('password.recover');

The issue is that when I submit the form I get the MethodNotAllowedHTTPException error. If i hit go back from the error page then my form loads with my form validation errors (since the form was submitted empty). So it is hitting the reset function in my AuthController but it is having some kind of routing error. If I try to submit the empty form it should just reload the page with the errors, rather than giving the exception error.

Am I missing something totally obvious here?

Upvotes: 0

Views: 44

Answers (1)

Toby Okeke
Toby Okeke

Reputation: 654

Form::open(array('route' => 'password.recover', 'method'=>'post'))

You are not passing the right http method. The route is expecting post but you are using the default which is get.

Upvotes: 1

Related Questions