Pass it down from the controller
@anilk sure. It was just to clean your code
<input type="text" name="search" value="{{request()->get('filter')['search'] ?? '' }}" >
@Sinnbeck Sir its throwing error as
undefined constant "search
@Sinnbeck one more question sir ...
for for the product search i have form like below.... i want to get selected for the options when select value matches in url like
http://gweb.test/jobs?filter[name]=kansas
http://gweb.test/services?filter[name]=kansas
http://gweb.test/accommodation?filter[name]=kansas
http://gweb.test/motor-vehicles?filter[name]=kansas
http://gweb.test/real-estate?filter[name]=kansas
i want to have options selected while visiting above url
my form is
<form action="{{ route('product.search') }}" method="GET">
<div class="input-group border-0">
<div class="input-group-text p-0">
<select class="form-select d-none d-xl-block" name="type" aria-label="Default select example">
<option value="market" @if (request()->has('market')) selected @endif>Market</option>
<option value="services" @if (request()->has('services')) selected @endif>Services</option>
<option value="jobs" @if (request()->has('jobs') && request()->get('jobs')==null) selected @endif>Jobs</option>
<option value="motor-vehicles" @if (request()->has('motor-vehicles')) selected @endif>Motor & Vehicles</option>
<option value="real-estate" @if (request()->has('real-estate')) selected @endif>Real Estate</option>
<option value="accommodations" @if (request()->has('accommodations')) selected @endif>Accommodations</option>
</select>
</div>
<input type="text" name="search" value="{{request()->get('filter')['search'] ?? '' }}" class="form-control" id="search_value" placeholder="Enter your search key ... ">
<div class="input-group-text p-0">
<button class="btn-search btn btn-hover-primary" type="submit">
Search
</button>
</div>
</div>
</form>
@smacy that's why you need to move it to the controller.. Then it's just a single variable you are working with
Please sign in or create an account to participate in this conversation.