未选中Laravel单选按钮

问题描述 投票:0回答:1

当我尝试检查一个选项时,其他选项应该自动取消选中,但不是我也尝试手动取消选中该选项,但是它不起作用

Radio Bottoms checked at the same time

代码

<div class="col-12">
                            <div class="custom-control custom-radio mb-5">
                                <input class="custom-control-input" type="radio" name="admin" id="example-radio1" value="option1"{{$user->hasRole('Admin') ? 'checked' : ''}}>
                                <label class="custom-control-label" for="example-radio1">Admin</label>
                            </div>
                            <div class="custom-control custom-radio mb-5">
                                <input class="custom-control-input" type="radio" name="editor" id="example-radio2" value="option1"{{$user->hasRole('Editor') ? 'checked' : ''}}>
                                <label class="custom-control-label" for="example-radio2">Editor</label>
                            </div>
                            <div class="custom-control custom-radio mb-5">
                                <input class="custom-control-input" type="radio" name="user" id="example-radio3" value="option1"{{$user->hasRole('User') ? 'checked' : ''}}>
                                <label class="custom-control-label" for="example-radio3">User</label>
                            </div>
                        </div>
html laravel
1个回答
0
投票

如@kerbholz所说,广播电台名称应相同。请参见下面的示例:

<div class="col-12">
        <div class="custom-control custom-radio mb-5">
                <input class="custom-control-input" type="radio" name="role" id="role" value="admin"{{$user->hasRole('Admin') ? 'checked' : ''}}>
                <label class="custom-control-label" for="example-radio1">Admin</label>
        </div>
        <div class="custom-control custom-radio mb-5">
                <input class="custom-control-input" type="radio" name="role" id="role" value="editor"{{$user->hasRole('Editor') ? 'checked' : ''}}>
                <label class="custom-control-label" for="example-radio2">Editor</label>
        </div>
        <div class="custom-control custom-radio mb-5">
                <input class="custom-control-input" type="radio" name="role" id="role" value="user"{{$user->hasRole('User') ? 'checked' : ''}}>
                <label class="custom-control-label" for="example-radio3">User</label>
        </div>
        </div>
</div>

现在,根据需要/需要在控制器中处理输入。

© www.soinside.com 2019 - 2024. All rights reserved.