{{ Form::open(array('route' => 'game/winner', 'class' => 'form game play')) }}
<ul>
<?php foreach($players as $player) : ?>
<li>
<div class="radio radio-primary">
<label>
{{ Form::radio('player', $player->id, false, ['class' => 'radio']) }}
<span class="circle"></span>
<span class="check"></span>
<?php echo $player->firstname; ?>
</label>
</div>
</li>
<?php endforeach; ?>
<li>
{{ Form::submit('End Game', array('class' => 'btn btn-success submit')) }}
</li>
</ul>{{ Form::close() }}
我循环浏览玩家并生成单选按钮,最多两个,然后用户选择一个获胜者并提交表单。如何传递未选择的值,以便我也可以在此表单定向的视图中使用该数据?
如果我
正确阅读了您的问题 - 您已经有了单选按钮列表 - 因为每个单选按钮代表一个$player
.
因此,只需获取路由game/winner
以在服务器端再次拉取$players
列表,然后简单地将用户选择的选定$player
传递给它。