If you want to show the radio button checked then you have to add the checked attribute in your input form. But if you want to checked it conditionally then this example is for you. In this tutorial, how to check radio button according to value retrieved from database. You will also see if condition in input field laravel cause we need a if condition to show checked unchecked radio button.

I will simply create an HTML form and show you radio button checked if condition in laravel. So let's see the example code of radio button checked if condition in php laravel application. I will use radio button in html for gender as an example.

laravel-radio-button-checked-if-condition-exampleSo let's see the source code of input radio checked and radio button checked if condition in laravel.

<form class="w-px-500 p-3 p-md-3" action="{{ route('user.store') }}" method="post" enctype="multipart/form-data">
    @csrf
    @php
        $gender = 'Male';
    @endphp
    <div class="row mb-3">
        <label class="col-sm-3 col-form-label">Gender</label>
        <div class="col-sm-9 mt-3">
            <input type="radio" name="gender" value="Male" {{ $gender === 'Male' ? 'checked' : '' }}> Male
            <input type="radio" name="gender" value="Female" {{ $gender === 'Female' ? 'checked' : '' }}> 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>

 

Read also: Multiple Radio Button Checked Condition In Laravel Blade

 

Conclusion

Hope this radio button checked if condition in laravel tutorial will help. After completing this laravel radio button checked tutorial, your concept will be clear about if condition in input field laravel. Hope this radio button checked if condition in php laravel tutorial will clear your concept about how to check radio button according to value retrieved from database.