固定在单选按钮中

时间:2018-06-20 11:00:09

标签: twitter-bootstrap laravel laravel-5 laravel-4 laravel-5.2

如图所示。我点击“卖出”按钮后点击“买入”按钮,另一个div通过单选按钮禁用。如何在Laravel中创建单选按钮组?我该如何选择买和卖?

enter image description here

<div class="form-group col-sm-5">
            {{ Form::radio('is_action', 1) }} Buy
            {{ Form::radio('is_action', 0) }} Sell
        </div>
        <div class="form-group col-sm-5">
            {{ Form::radio('is_action', 1) }} Buy
            {{ Form::radio('is_action', 0) }} Sell
        </div>

1 个答案:

答案 0 :(得分:1)

当多个具有相同名称的选项时,只能选择一个单选按钮。

    <div class="form-group col-sm-5">
        {{ Form::radio('is_action', 1) }} Buy
        {{ Form::radio('is_action', 0) }} Sell  
    </div>
    <div class="form-group col-sm-5">
        {{ Form::radio('is_action', 1) }} Buy
        {{ Form::radio('is_action', 0) }} Sell
    </div>    

在这里您只能从这四个单选按钮中选择一个。如果要选择更多,请添加如下所示的不同名称;

    <div class="form-group col-sm-5">
        {{ Form::radio('is_action_1', 1) }} Buy
        {{ Form::radio('is_action_2', 0) }} Sell  
    </div>
    <div class="form-group col-sm-5">
        {{ Form::radio('is_action_3', 1) }} Buy
        {{ Form::radio('is_action_4', 0) }} Sell
    </div>

有关更多详细信息,请参见http://laravel-recipes.com/recipes/168/creating-a-radio-button-input-field