", expecting ")" And here is my code: {{Form::open (array ('url' => 'logincheck'))}}

{{Form::" /> ", expecting ")" And here is my code: {{Form::open (array ('url' => 'logincheck'))}}

{{Form::" /> ", expecting ")" And here is my code: {{Form::open (array ('url' => 'logincheck'))}}

{{Form::"/>

Can't seem to find a solution for this error in Laravel

128 Views Asked by At

Here is the error:

syntax error, unexpected token "=>", expecting ")"

And here is my code:

{{Form::open (array ('url' => 'logincheck'))}}

    <p> {{Form::text ('username', string ('placeholder'=>'Username','maxlength'=>30))}} </p>

    <p> {{Form::password ('password', string('placeholder'=>'Password','maxlength'=>30))}} </p>

    <p> {{Form::submit ('Submit')}} </p>

{{Form::close ()}}
4

There are 4 best solutions below

0
zlodes On

Change the string(... to array(...

I recommend you use the short array syntax like that:

{{ Form::text('username', ['placeholder' => 'Username', 'maxlength' => 30]) }}
0
Niteya Shah On

The method signature is public function text($name, $value = null, $options = []) So to pass your options, you need to use an array.

{{ Form::open (array ('url' => 'logincheck')) }}
    

    <p> {{ Form::text ('username', '',['placeholder'=>'Username','maxlength'=>30]) }} </p>

    <p> {{ Form::password ('password', '', ['placeholder'=>'Password','maxlength'=>30]) }} </p>

    <p> {{ Form::submit ('Submit') }} </p>

{{ Form::close ()}}
2
P. K. Tharindu On

Try refining your input fields like so:

{{ Form::text('username', null, array('placeholder' => 'Username','maxlength' => 30 )) }}

{{ Form::password('password', null, array('placeholder' => 'Password','maxlength' => 30 )) }}

BTW, what version of Laravel are you using?

0
Miqayel Srapionyan On

I replaced the string with array Try this code

{{Form::open (array ('url' => 'logincheck'))}}

    <p> {{Form::text ('username', array('placeholder'=>'Username','maxlength'=>30))}} </p>

    <p> {{Form::password ('password', array('placeholder'=>'Password','maxlength'=>30))}} </p>

    <p> {{Form::submit ('Submit')}} </p>

{{Form::close ()}}