i'm stuck at this very basic form, that i could not accomplish, which i want to build a search form with an text input, and two select controls, with a route that accept 3 parameters, the problem that when the i submit the form, it map the parameters with the question mark, not the Laravel way,
View:
{ Form::open(['route' => 'search', 'method' => 'GET'])}}
<input type="text" name="term"/>
<select name="category" id="">
<option value="auto">Auto</option>
<option value="moto">Moto</option>
</select>
{{ Form::submit('Send') }}
{{ Form::close() }}
Route:
Route::get('/search/{category}/{term}', ['as' => 'search', 'uses' => 'SearchController@search']);
When i submit the form it redirect me to
search/%7Bcategory%7D/%7Bterm%7D?term=asdasd&category=auto
How can i pass these paramters to my route with the Laravel way, and without Javascript ! :D
You can not change the action url of the form while filling it (you can with Javascript but that would be verycomplicated).
Instead take the submitted parameters with Input::get('parametername').
Route::get('/search', ['as' => 'search', 'uses' => 'SearchController@search']);
SearchController
function search()//no parameters from route
{
$category = Input::get('category');
echo $category;
$term = Input::get('term');
echo $term;
}
Hello
No way javascript :p
finally i did a function red_search() that redirect to /search/{category}/{term}
public function red_search()
{
$url=Request::all();
return redirect('search/'.$url['category'].'/'.$url['term']);
}
thank you ;)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community