In this laravel radio button tutorial, we will see how to get selected radio button value in laravel controller. I will create a simple radion button form for this tutorial then I will show you this radio button in laravel 9. I will create radio button for gender. Male and Female value will be the options. If user select the value and then submit, then we will accept the selected value from the Laravel controller.

laravel-radio-button-from-example

So let's see the source code form of the radio button example in laravel 9:

<form class="w-px-500 p-3 p-md-3" action="{{ route('user.store') }}" method="post">
    @csrf
    <div class="row mb-3">
        <label class="col-sm-3 col-form-label">Gender</label>
        <div class="col-sm-9">
            <input type="radio" name="gender" value="Male"> Male
            <input type="radio" name="gender" value="Female"> Female
        </div>
    </div>

    <div class="row mb-3">
        <label class="col-sm-3 col-form-label"></label>
        <div class="col-sm-9">
            <button type="submit" class="btn btn-success btn-block text-white">Submit</button>
        </div>
    </div>
</form>

 

Now use your controller like:

App\Http\Controllers\UserController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    public function store(Request $request)
    {   
        return $request->gender;
    }
}

 

Now submit the form and see the output:

{
   "_token": "xDbOBo3TxWuc5xEbvExTv3E8lSLjiGsEdLeoqMjr",
   "gender": "Male"
}

 

Read also: Laravel Upload File Multipart/Form-Data Example

 

Conclusion

Hope this radio button laravel 9 tutorial will help. After completing this how to get selected radio button value in laravel controller tutorial, your concept will be clear about how to use radio button in laravel. Hope this radio button example in laravel 9 tutorial will clear your concept about laravel blade radio button.