mardi 6 juin 2017

How to get a value from controller to view in laravel?

I have a simple input form with a text input field and a submit button. I am trying to get the value from the input field to be displayed again on the same page after the submit button is clicked. So far laravel always throws an error that the variable is undefined.

Route:

Route::get('/find/names', "FindController@get_name")->name('names');

Controller

 public function get_name(){
         $name = Input::get('name_by_user');
         return $name;
    }

view

        <form role="form" method="GET">
                    <div class="row">
                        <div class="form-group">
                            <div class="input-group">
                                <input type="text" name="name_by_user"/>
                                <span class="input-group-btn">
                                    <button class="btn search-button" type="submit">
                                    <span aria-hidden="true">
                                    <span>Search</span>
                                    </button>
                                </span>
                                </span>
                            </div>
                        </div>
                    </div>           
                </form>

  display name after submitting:  



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire