htmlentities()期望参数1为字符串,给定数组..

时间:2016-01-23 21:59:30

标签: laravel laravel-4 laravel-5 laravel-5.1 laravel-routing

我的表单代码:

<p>{!!Form::open(array("","id"=>"form"))!!}</p>
<p>Initial barcode :&nbsp </p>
<p>{!! Form::text('initialbarcode',array("id"=>"initialbarcode"))!!}</p>
<p>Barcode3 :&nbsp </p>
<p>{!! Form::text('barcode3',array("id"=>"barcode3"))!!}</p>
<p>Quantity :&nbsp </p>
<p>{!! Form::text('qty',array("id"=>"qty"))!!}</p>
<p>Kgs :&nbsp </p>
<p>{!! Form::text('kgs',array("id"=>"kgs"))!!}</p>
<p>Price :&nbsp </p>
<p>{!! Form::text('price',array("id"=>"price"))!!}</p>
<p>{!! Form::text('name',array("id"=>"name"))!!}</p>
<p><select name="category" id="category"></p>
@foreach($options as $option)
<option>{{$option->category}}</option>
@endforeach
</select>
<p>{!! Form::close()!!}</p>

此处此代码返回以下错误: htmlentities()期望参数1为字符串,给定数组(查看:C:\ Users \ Toshiba \ farmzop \ resources \ views \ nonfz \ nonfz.blade.php)

1 个答案:

答案 0 :(得分:1)

请注意Form::text方法的签名:

/**
* Create a text input field.
*
* @param  string $name
* @param  string $value
* @param  array  $options
*
* @return string
*/
public function text($name, $value = null, $options = [])

只需改变:

{!! Form::text('initialbarcode',array("id"=>"initialbarcode"))!!}

{!! Form::text('initialbarcode', null, ["id"=>"initialbarcode"]) !!}