2

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);
4
  • 1
    Where are you trying to print_r the value you get in that last code snippet? Commented Apr 23, 2015 at 5:13
  • please tell us where you are trying to print_r... Commented Apr 23, 2015 at 5:18
  • Sorry, Right underneath $status_Id = Input::get('status_Id'); @Scopey Commented Apr 23, 2015 at 5:19
  • you should use form submit not anchor tag link for delete and put form action as {{{ url("delete_comment_action/$swagger->Id") }}}" Commented Apr 23, 2015 at 5:24

2 Answers 2

7

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>
Sign up to request clarification or add additional context in comments.

1 Comment

there is a function called debug die in laravel, you can call it like : dd($value, $array, ...);
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.