如何在Laravel中获得选定的单选按钮值

问题描述 投票:5回答:2

您好,所有如何获取选定的单选按钮值。我想将值存储在我的表中选中单选按钮的位置。

我的控制器代码传递给View $ result

        $result =     DB::table('table')
                                ->where('name', $name)
                                ->where('code', $code)
                                ->get();

        return  View::make('home.search_result')            
                       ->with('result', $result);

在我的查看代码中,我有单选按钮。

{{ Form::open(array('action' => 'BookingController@postValue',  'class'=>'well', 'method' => 'GET')) }}         
<table id="search" class="table table-striped table-hover">
    <thead>
        <tr>
            <th></th>
            <th>Name</th>
            <th>Code</th>                                                                                                              
        </tr>
    </thead>
    <tbody> 
        @foreach($result as $result)                                    
            <tr class="success">    
                <td>{{ Form::radio('result') }}
                <td>{{ $result->name}}</td>                 
                <td>{{ $result->code}}</td>                 
            </tr>                       
        @endforeach                           
    </tfoot>
</table>           

{{ Form::submit('Add', array('class' => 'btn btn-info')) }}         
{{ Form::close() }}         

因此,当我单击“添加”按钮时,我尝试将已选中的单选按钮值传递给我的postValue函数。

您好,所有如何获取选定的单选按钮值。我想将值存储在我的表中选中单选按钮的位置。我的控制器代码传递给View $ result $ result = DB :: table('table')...

laravel-4 radio-button return-value
2个回答
8
投票

您需要为单选按钮提供一个值。您所提供的只是一个名字。


3
投票

您需要给单选按钮起一个名字。

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