Reputation: 2396
I have created a Form
in a blade
template. This form sends a POST
request to search.postQuery
, so I can get the search query and then do something with it and return a View
.
This is the route I have defined:
Route::post('/search/{query}', ['as' => 'search.postQuery', 'uses' => 'SearchController@postQuery'])->where('query', '[a-zA-Z0-9]+');
My form looks like this:
{{ Form::open(array('method' => 'POST', 'route' => array('search.postQuery')) }}
{{ Form::text('searchQuery') }}
{{ Form::submit('Zoeken!') }}
{{ Form::close() }}
This is the method the route calls on POST
:
public function postQuery($query)
{
var_dump("Landed here");
}
And finally, the error Laravel poses me with is a NotFoundHttpException
.
I also discovered that Laravel is constructing a rather strange URL when I press submit: http://homestead.app/search/%7Bquery%7D
What am I doing wrong? As to my knowledge, I'm not doing something very strange?
Upvotes: 1
Views: 104
Reputation: 614
This is your error
{{ Form::open(array('route'=>'search.postQuery','method' => 'POST')) }}
{{ Form::text('searchQuery') }}
{{ Form::submit('Zoeken!') }}
{{ Form::close() }}
Upvotes: 2