2 回答

TA貢獻1812條經驗 獲得超5個贊
laravel 默認轉義數據。每當您從數據庫中檢索數據以放入刀片視圖時,它都沒有給出任何錯誤。數據庫數據轉義是一種很好的做法。
當您顯示數據時,有一些不需要的數據。在嘗試保存數據之前,您可以trim($yourString)從字符串的開頭和結尾刪除不需要的空格。
并且您不能讓空白或空字符串在您的刀片中查看。那么,您可能會使用blank($var)它來檢查它是否為空白?
<form method="POST" action="{{ route('setups.update', $data->id) }}">
<div class="row">
<div class="col-md-12" id="socialGroup">
@foreach($socials as $social)
@if(!blank($social))
<div class="form-group socialField">
<label class="bmd-label-floating">Social Links</label>
<input type="text" name="social[]" value="{{ $social }}" class="form-control">
<a href="#" class="addField"><i class="fa fa-plus"></i></a>
</div>
@endif
@endforeach
<div class="alert alert-danger" id="socialError">
<p><strong>Sorry! </strong>You've reached the max number for social links form.</p>
</div>
</div>
</div>

TA貢獻1831條經驗 獲得超9個贊
解決了!我剛剛在我的 SetupController@update 中添加了這段代碼
if (Input::has('social')) {
$data['social'] = implode(',',$data['social']);
}
- 2 回答
- 0 關注
- 161 瀏覽
添加回答
舉報