How to get select value text with Laravel?

How can I get select option with Laravel? Not Select value just Text.

For example;

<select name="assignedUser">
    <option value="123">John</option>
</select>

I want to take the name John. Because the user needs the name and ID.

$request->input('assigned')->text() like this

I hope, You understand me... Can you help me ? Thank you.

Upvotes: 0

Views: 1300

Answers (1)

VIKAS KATARIYA
VIKAS KATARIYA

Reputation: 6005

You can also refer this example

$selectionOptions = [1 => 'A', 2 => 'B', 3 => 'C'];
$selected = $selectionOptions[$request->input('selection-list')];

Or you can just update the HTML to have the text as the value

<select name="selection-list">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
</select>

Upvotes: 3

Related Questions