htmlentities() expects parameter 1 to be string, array given

佐手、 提交于 2019-12-12 09:54:24

问题


I'm trying to add a class to a laravel form. The array is being passed as the third argument, as required, but I get the above error.

{{ Form::input('text', $variable->name, array('class' => 'form-control')) }}

If I get rid of the third argument, the form displays as expected (unstyled). I can't see what I'm doing wrong here - can anyone help?


回答1:


{{ Form::text('text', $variable->name, array('class' => 'form-control')) }}



回答2:


I can see from the api that there is another argument expected:

http://laravel.com/api/source-class-Illuminate.Html.FormBuilder.html#235-246

('text', $name, $value, $options)



回答3:


Your array needs to be the fourth argument to Form::input() - the third is the 'default' value. See Laravel's FormBuilder class:

public function input($type, $name, $value = null, $options = array())


来源:https://stackoverflow.com/questions/21732931/htmlentities-expects-parameter-1-to-be-string-array-given

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!