Enes Genc
Enes Genc

Reputation: 39

get select box value Laravel

I use laravel 5.4.

   <select name="type" id="type">
     <option value="0">title1</option>
     <option value="1" selected>title2</option>
     <option value="2">title3</option>
    </select>

I record the data to the database. But I can not get the value of the select box tag. I am using the following codes in Controller and as a result I get text.

$type = $request->get('type');
  or 
$type = Input::get('type');

print_r($type) ;

result: "title2"

I did not find any results in my research. Please help me.Is there a recommendation?

Upvotes: 1

Views: 9781

Answers (2)

Hamidreza Ghanbari
Hamidreza Ghanbari

Reputation: 307

the easiest way is $request->type to get value of select option in your controller ;)

Upvotes: 0

Mohammad hayajneh
Mohammad hayajneh

Reputation: 674

change $request->get('type') to $request->input('type')

Upvotes: 2

Related Questions