使用 laravel 5.2 调用未定义函数 Form()
Call to undefined function Form() using laravel 5.2
当我进入我的视图时,出现以下错误:
FatalErrorException in 9edd5e400844b5418c6227c302e89f04657fb615.php line 3:
Call to undefined function Form()
我的查看文件:
{!!Form::open(array('url'=>'resetpwd','method'=>'PUT')) ;!!}
<p>{!!Form(password('password'));!!}</p>
{!!$errors->first('password');!!}
{!!Form::hidden('code',$code);!!}
<p> {!!Form::submit('Reset Passsword');!!} </p>
{!!Form::close();!!}
{!!$errors->first('reseterror');!!}
我假设您已经安装了 Laravel Recepie. You do not declare Form::password()
method correctly.Edit your code with below changes hope it will be helped you.See 如何在 Laravel Recepie 中使用此方法。
将 {!!Form(password('password'));!!}
更改为 {!!Form::password('password');!!}
表单不是核心组件的一部分,因此您需要将其添加到 laravel。
为此,您需要编辑 laravel 主目录中的 composer.json 文件。
更改此行
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
到
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*"
},
然后在您的终端中 运行 composer update
。它将添加所有包含表单的集合。
接下来,您必须将新提供者添加到 config/app.php.
的提供者数组中
您会在 app.php
中找到它
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
....................
需要加行Collective\Html\HtmlServiceProvider::class,
所以将供应商更改为
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Collective\Html\HtmlServiceProvider::class, ....
最后一步是将两个 class 别名添加到 config/app 的别名数组。php
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,...
ADD 额外的两个classes FORM,HTML那里
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,...
现在您可以使用laravel中的表格了。
当我进入我的视图时,出现以下错误:
FatalErrorException in 9edd5e400844b5418c6227c302e89f04657fb615.php line 3: Call to undefined function Form()
我的查看文件:
{!!Form::open(array('url'=>'resetpwd','method'=>'PUT')) ;!!}
<p>{!!Form(password('password'));!!}</p>
{!!$errors->first('password');!!}
{!!Form::hidden('code',$code);!!}
<p> {!!Form::submit('Reset Passsword');!!} </p>
{!!Form::close();!!}
{!!$errors->first('reseterror');!!}
我假设您已经安装了 Laravel Recepie. You do not declare Form::password()
method correctly.Edit your code with below changes hope it will be helped you.See 如何在 Laravel Recepie 中使用此方法。
将 {!!Form(password('password'));!!}
更改为 {!!Form::password('password');!!}
表单不是核心组件的一部分,因此您需要将其添加到 laravel。 为此,您需要编辑 laravel 主目录中的 composer.json 文件。 更改此行
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
到
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*"
},
然后在您的终端中 运行 composer update
。它将添加所有包含表单的集合。
接下来,您必须将新提供者添加到 config/app.php.
的提供者数组中您会在 app.php
中找到它 'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
....................
需要加行Collective\Html\HtmlServiceProvider::class,
所以将供应商更改为
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Collective\Html\HtmlServiceProvider::class, ....
最后一步是将两个 class 别名添加到 config/app 的别名数组。php
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,...
ADD 额外的两个classes FORM,HTML那里
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,...
现在您可以使用laravel中的表格了。