简体   繁体   中英

Getting the Form input value in Laravel

Are there other ways to get value of an <input> in laravel besides Input::get('name'); ?

Here is my route that tries and get the value

Route::get('delete_comment_action/{id}', function($id)/
{

    $status_Id = Input::get('status_Id');
    print_r($status_Id);
    exit();

    return Redirect::back();
});

here is the form that should have the data in it

<form action="" method="get">
            <input type="hidden" name ="status_Id" value="{{$swagger->status_Id}}">
             <a href ="{{{ url("delete_comment_action/$swagger->Id") }}}"><button type="button" class="btn btn-danger">Delete</button></a>
            </form>

Status_Id should at least equal 1, when i try using, but instead it just displays a blank page.

$variable = Input::get('status_Id'); 

print_r($variable);

your routes looks okay but change form submit tag instead link

Route::get('delete_comment_action/{id}', function($id){

    $status_Id = Input::get('status_Id');
    print_r($status_Id);
    exit();

    return Redirect::back();
});

In Form view change form action and replace anchor tag link with submit button

  <form action="{{{ url("delete_comment_action/$swagger->Id") }}}" method="get">
        <input type="hidden" name ="status_Id" value="{{$swagger->status_Id}}">
        <input type="submit" value="Delete">
  </form>

You are trying to use same route twice. You can't use it. What you have to do is separate routes like the following

This route is to show view

Route::get('test', function() {
    return View::make('example');
});

This route will handle when you submit your form

Route::get('newtest', function() {
    dd(Input::all());
});

In your example.blade.php

<form action="" method="get">
     <input type="text" name="hello">
     <input type="submit" value="Submit">
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM