Search code examples
phplaravellaravel-5laravelcollective

Laravel & LaravelCollective HTML/Forms Error


I'm building a simple form with a username and password.

When I construct a username field like this:

{{ Form::text('username') }}

My page loads without issue. As soon as I want to define a class like this:

{{ Form::text('username', ['class' => 'awesome']) }}

I get an error, like so:

ErrorException in HtmlBuilder.php line 65:
htmlentities() expects parameter 1 to be string, array given

Haven't been able to find any info regarding this error online. These examples are taken STRAIGHT from the LaravelCollective documentation.

Any ideas? Thanks!


Solution

  • You should pass the class in the third parameter like so:

    {{ Form::text('username', null, ['class' => 'awesome']) }}
    

    or:

    {{ Form::text('username', '', ['class' => 'awesome']) }}
    

    The second parameter is the value field