Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting value of a submit button in Laravel 5.3

Tags:

php

laravel

I have a form on my page

 <form method="post" action="{{url('/vpage')}}"> 
 <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <div class="w100">
        <button name="hostel1" class="submitBTN addnowBtn" type="submit" value="The Venetian"> Add Now</button>
    </div><!--w100-->
 </form>

I getting the request printed in my controller like

    public function vegaspage(Request $request){
    dd($request);
    die;
   } 

I have also have many fields on my page , when the request params comes to browser the submit button value is not coming in request Any ideas ?

like image 328
Muhammad Sipra Avatar asked Feb 27 '17 07:02

Muhammad Sipra


1 Answers

Inside your controller function try this:

Input::get('hostel1', 'NA');

// It will return its value ie `The Venetian` otherwise `NA`

Note: The second parameter of Input::get() is the default value.

like image 69
Mayank Pandeyz Avatar answered Oct 05 '22 23:10

Mayank Pandeyz