[英]Laravel 5 Get old Radio Button Input after validation fails
如何正確獲取Laravel 5中的舊單選按鈕值? 因為使用old('radiobutton1'); 返回一個包含“ on”的字符串,該字符串在第一次失敗時是正確的,並返回正確的按鈕,但是如果您選擇第二個單選按鈕(在這種情況下只有兩個選項),則兩個舊按鈕都將返回“ on”字符串('radiobutton1')和old('radiobutton2')
代碼示例:
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary @if(old('radiobutton1') == "on") active @endif">
<input type="radio" name="radiobutton1" id="radiobutton1" @if(old('radiobutton1') == "on") checked @endif autocomplete="off"> Option1
</label>
<label class="btn btn-primary @if(old('radiobutton2') == "on") active @endif">
<input type="radio" name="radiobutton2" id="radiobutton2" @if(old('radiobutton2') == "on") checked @endif autocomplete="off"> Option2
</label>
</div>
聚苯乙烯
如果需要的話,單選按鈕可以使用Twitter Bootstraps的JavaScript單選按鈕設置樣式。
我認為您應該使用Form Facade。
它處理默認值並保留舊值。
{!! Form ::radio('name', 'value', true)!!}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.