laravel-4 - 如何在Laravel中获取选定的单选按钮值

标签 laravel-4 radio-button return-value

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

我的 Controller 代码传递给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函数。

最佳答案

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

<td>{{ Form::radio('result', $result->code) }}

然后,在处理表单的 Controller 中,您可以获取值。
$result = Input::get('result');

关于laravel-4 - 如何在Laravel中获取选定的单选按钮值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23321294/

相关文章:

c# - 何时使用 JsonResult 而不是 ActionResult

php - Laravel 4.2 ORM - 查询与之间各种表的关系

php - Laravel 数据透视表和模型事件

jquery - 使用 Bootstrap 让按钮组像单选按钮一样工作

Angular 2 : how to create radio buttons from enum and add two-way binding?

java - 如何在 JavaFX 中默认检查单选按钮?

python - 如何从 Python 脚本返回一个值作为 Bash 变量?

C:从函数中的循环中删除多个值的方法

php - 如何在 Laravel 中阻止相同类型的用户访问其他数据?

php - Laravel Excel - 仅返回行的第一列