lundi 3 décembre 2018

Controller method not being called

I'm having an issue where my Laravel method isn't being called when I submit a form.

<form class="form" method="post" action="/contact">
<div class="form__field">
<input id="name" name="name" type="text"><label for="name">Name</label>
</div>
<div class="form__field">
<input id="email" name="email" type="email"><label for="email">Email</label>
</div>
<div class="form__field">
<select id="select-floor" name="select-floor">
<option disabled selected>
I'm interested in floor…
</option>
<option value="basement">
Front house
</option>
<option value="ground-floor">
Ground floor
</option>
<option value="first-floor">
First floor
</option>
<option value="second-floor">
Second floor
</option>
<option value="third-floor">
Third floor
</option>
</select><label class="visually-hidden" for="select-floor">Select floor…</label>
</div>
<div class="form__field">
<textarea name="message"></textarea><label for="message">Message</label>
</div><button class="" type="submit">Send Enquiry</button>
</form>

This is my route file:

Route::get('/contact', function () {
  return view('pages/contact', [
    'title' => 'Contact',
    'description' => ''
  ]);
});

Route::post('/contact','ContactController@sendEmail');

And in my controller I have:

class ContactController extends Controller
{
    public function sendEmail(){
        dd('test');
    }
}

What I am expecting to happen is that the string test is outputted and the application should just end. What is actually happening is that form page is just reloading.

I checked the developer console and I can see a 419 error but the page is then displayed instead of the 419 error.

I am completely stumped. What am I missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire