Normally you don't have localhost in the route.
Dynamic form action with method GET
Im making car ads web part. User in form can choose what make he is looking for, model, year ..... So i need to assemble URL with selections which controller could process later.
This is my blade:
<form action="{{route('ads_list.index') }}" method="GET">
<label>Make</label>
<select id="makes_select" name="make_id">
<option>SAAB</option>
<option>TRIUMPH</option>
<option>LOTUS</option>
</select>
<select id="year_select" name="year">
<option>2000</option>
<option>2001</option>
<option>2002</option>
</select>
<button type="submit"> SUBMIT </button>
</form>
This is my routes
Route::resource('localhost' ,App\Http\Controllers\Skelbimai_mainController::class); //here i choose filters
Route::resource('localhost/ads_list' ,App\Http\Controllers\Ads_listController::class); //here i want display ads according to filters
If i submit data i selected in form, I get redirected to intended route ads_list with all variables in URL (localhost/ads_list?make_id=SAAB&year=2000). BUT my resource controller doesn't return anything, it's just blank page (they should return("damn this works"). According to route:list route exist and is correct, just all those extra values to URL messes up something. If i simply add csrf and change method to POST i do get controller return value, but then URL won't have variables.
I did kinda solve this.
<form action="localhost/ads_list/index" method="GET">
For some strange reasons it returns show method, not index. I tried some other variations, but this was the only one that worked. This way i can access at least one method of resource controller and have all variables in URL. Using localhost.ads_list.index or similar variations return 404 error.
Please or to participate in this conversation.