Reputation: 1047
I'm using Laravel 5.3 and I have a client registration form, then when a button is clicked, it goes to the corresponding route and then from there to the create method.
I'm having trouble sending my selected dropdown list item to the controller. Here is my dropdown list:
<div class="form-group">
<label for="card_type" class="col-md-4 control-label">Card</label>
<div class="col-md-6">
<select class="form-control" name="card_type" id="card_type">
<option id="card_id" name="card_id" value="1">One</option>
<option id="card_id" name="card_id" value="2">Two</option>
<option id="card_id" name="card_id" value="3">Three</option>
<option id="card_id" name="card_id" value="4">Four</option>
<option id="card_id" name="card_id" value="5">Five</option>
<option id="card_id" name="card_id" value="6">Six</option>
<option id="card_id" name="card_id" value="7">Seven</option>
</select>
</div>
</div>
Here is what I've tried in the controller to retrieve the selected item:
$request->input('card_id'),
and $request->input('card_type'),
But it's returning Null
. Any idea why?
Upvotes: 0
Views: 1955
Reputation: 1353
Use input('card_type'), AND DELETE name="card_id" from your options, you need insert only one name in your input, it must be inserted in select section html
Upvotes: 1