vendredi 15 janvier 2016

Is there any better way to fill form input values in the above search form?

I have a search form like below with just one field

{!! Form::open(array('method' => 'POST', 
        'action' => 'CustomerController@SearchCustomers', 
        'class' => "form-horizontal form-label-left")) !!}
    {!! csrf_field() !!}
        <input type="text" class="form-control" name="Customer">
        <button type="submit">Search</button>
{!! Form::close() !!}

Below is code in Controller

$AllCustomers = \App\Models\Customer_Model
    ::where('Customer', 'LIKE', '%'.$Customer.'%')
    ->get();
return View('Customer.List', array('AllCustomers' => $AllCustomers));

What I am trying ?

When the form is submitted for search, in the view , I should be able to view the keyword again in the textbox. For that I am doing below.

return View('Customer.List', array('AllCustomers' => $AllCustomers, 'Key' => $Customer));

and now in the Form, I am doing below.

<input type="text" class="form-control" name="Customer" value="{{$Key}}">

Question

Is there any better way to fill form input values in the above search form ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire