我正在与无线电输入组一起开发Laravel,并试图传递给控制器。下面是我的刀片。
@foreach ($testtransactions as $key => $testtransaction)
<div class="form-check">
<input type="radio" name="choice{{$key}}" id="1" value="1" class="form-check-input">
</div>
<div class="form-check">
<input type="radio" name="choice{{$key}}" id="2" value="2" class="form-check-input">
</div>
<div class="form-check">
<input type="radio" name="choice{{$key}}" id="3" value="3" class="form-check-input">
</div>
<div class="form-check">
<input type="radio" name="choice{{$key}}" id="4" value="4" class="form-check-input">
</div>
@endforeach
我尝试在控制器中获取以下代码的值,但未成功。
public function TestSave(Request $request){
$choices = $request->choice;
return $choices;
}
任何建议或指导对此将不胜感激,谢谢
这是简单的HTML。假设$key
是唯一的,则需要输入单选按钮的名称choice[{{$key}}]
。
在后端/控制器中访问它就像$request->choice
记住它将是一个数组一样。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句