3

我刚刚升级到 Laravel 5.1,我正在创建一个带有“文本”和“数字”输入的简单表单。当我需要将我的输入字段之一声明为数字时,我的问题就来了:

{!! Form::number('otp', null, ['class' => 'form-control', 'placeholder' => 'OTP']) !!}

它输出此错误:方法号不存在。上瘾,我在文档中看不到“Html and Forms”部分,似乎他们删除了它。

有人对 Laravel 5.1 有同样的问题吗?

4

2 回答 2

3

您可以使用{!! Form::input('number', 'otp', null, ['class' => 'form-control']) !!}.

于 2015-07-04T07:08:04.003 回答
3

似乎 5.1 中更改了一些规则,所以要解决这个问题,首先更新 composer.json:

"require": {
    "laravelcollective/html": "5.1.*"
}

然后 app.php 文件:

'providers' => [
   // ...
   Collective\Html\HtmlServiceProvider::class,
   // ...
],


'aliases' => [
   // ...
     'Form' => Collective\Html\FormFacade::class,
     'Html' => Collective\Html\HtmlFacade::class,
   // ...
],

来源: http: //laravelcollective.com/docs/5.1/html

于 2015-07-04T14:04:28.147 回答