1
我試圖根據價格(從高到低和從低到高)在搜索頁面中記錄(旅遊),用提交更改的表單事件。下面是窗體的代碼:htmlspecialchars()期望參數1是字符串,數組給定laravel
{!!Form::open(['route' => 'short','method' => 'GET', 'role' => 'search','class'=>'select-filters'])!!}
<input type="hidden" name="country" value="{{$country}}">
<input type="hidden" name="category" value="{{$category}}">
<input type="hidden" name="days" value="{{$days}}">
<select name="sort_price" id="sort-price" onchange="this.form.submit()">
<option value="" selected="">Sort by price</option>
<option value="lower">Lowest price</option>
<option value="higher">Highest price</option>
</select>
{!! Form::close() !!}
,我已經初始化值在同一個頁面,但給錯誤htmlspecialchars() expects parameter 1 to be string, array given
:
@if(Request::only('country') != null)
{{$country = Request::only('country')}}
@else
{{ $country = null }}
@endif
@if(Request::only('category') != null)
{{$category = Request::only('category')}}
@else
{{ $category = null }}
@endif
@if(Request::only('days') != null)
{{$days = Request::only('days')}}
@else
{{ $days = null }}
@endif
在Request::only()
值被從搜索表單傳遞在索引頁面。當我死和轉儲:
{{dd(Request::only('country','category','days'))}}
我拋出以陣列形式傳入的值
{{dd(Request::only('country'))}}
或
{{dd(Request::only('category'))}}
或
{{dd(Request::only('days'))}}
你的名字屬性! –
抱歉讓我糾正它。 –