【问题标题】:Can't seem to find a solution for this error in Laravel在 Laravel 中似乎无法找到解决此错误的方法
【发布时间】:2021-05-08 18:36:58
【问题描述】:

这是错误:

语法错误,意外标记“=>”,应为“)”

这是我的代码:

{{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 ()}}

【问题讨论】:

标签: laravel laravelcollective


【解决方案1】:

将string(...更改为array(...

我建议你使用这样的短数组语法:

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

【讨论】:

    【解决方案2】:

    方法签名是public function text($name, $value = null, $options = []) 所以要传递你的选项,你需要使用一个数组。

    {{ 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 ()}}
    

    【讨论】:

      【解决方案3】:

      尝试像这样优化您的输入字段:

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

      顺便说一句,你使用的是什么版本的 Laravel?

      【讨论】:

      • laravel Collective 仍然支持它。
      • 嗯!不知道那个。谢谢!
      【解决方案4】:

      我将string 替换为array 试试这个代码

      {{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 ()}}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-28
        • 1970-01-01
        • 2011-05-13
        相关资源
        最近更新 更多