I am creating a search engine and i want to check the database and fill in the hidden fields in the form if the search field brings back a match in the database. So for example if the user entered London and it had a match in my city table, i would want the hidden id and country_id fields filled with the city id and its related country id so that on the search page i would get a url like. Can this be done?
'search?searchinput=London&City=1&Country=1
I have two tables both connected through the relationship:
City: id, name, country_id
Country: id, country,
HTML form:
<div class="search-homepage-input">
{!! Form::open(['route' => 'search.index', 'method' => 'GET']) !!}
<div class="col-md-9 col-l">
{!! Form::text('searchinput', null, array('class' => 'form-control ', 'maxlength' =>'50', 'placeholder' => 'Search by city. Eg. London, New York, Milan...')) !!}
</div>
{!! Form::hidden('country', null, array('id' => 'country')) !!}
{!! Form::hidden('city', null, array('id' => 'city')) !!}
<div class="col-md-3 col-r">
{!! Form::submit('Find Shops', array('class' => 'btn btn-homepage-search')) !!}
</div>
{!! Form::close() !!}
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire