FormBuilder.php第241行中的Laravel ErrorException:

时间:2016-11-29 05:55:47

标签: laravel

我只是想尝试htmlcollective laravel,但我得到了错误

@extends('layouts.app')

@section('content')

  <h1>Create Post</h1>

  {{--<form method="post" action="/posts">--}}

  {!! Form::open(['method'=>'POST', 'action'=>'PostsController@store']) !!}
    <div class="form-group">
        {!! Form::label(['title', 'Title:']) !!}
    </div>
 {!! Form::close() !!}
@endsection

我错了这个

ErrorException in FormBuilder.php line 241: ucwords() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\cms\resources\views\posts\create.blade.php)

    in FormBuilder.php line 241
    at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
    at PhpEngine->evaluatePath('C:\xampp\htdocs\cms\storage\framework\views/2643c26b13a33e97e70f9171a92a68a8f3ee0af4.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in CompilerEngine.php line 59
    at CompilerEngine->get('C:\xampp\htdocs\cms\resources\views/posts/create.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag))) in View.php line 149
    at View->getContents() in View.php line 120
    at View->renderContents() in View.php line 85
    at View->render() in Response.php line 45
    at Response->setContent(object(View)) in Response.php line 201
    at Response->__construct(object(View)) in Router.php line 1017
    at Router->prepareResponse(object(Request), object(View)) in Router.php line 643
    at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
    at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
    at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
    at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    at Pipeline->then(object(Closure)) in Router.php line 644
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
    at Router->dispatchToRoute(object(Request)) in Router.php line 596
    at Router->dispatch(object(Request)) in Kernel.php line 267
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
    at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    at Pipeline->then(object(Closure)) in Kernel.php line 149
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
    at Kernel->handle(object(Request)) in index.php line 54

Laravel的问题在哪里?我不知道,什么可以触发这个,但我没有做任何事情。你知道哪里可能有问题吗?该项目在Laravel 5.3中编程。谢谢。

1 个答案:

答案 0 :(得分:2)

Form::label()的正确代码应如下所示:

{!! Form::label('title', 'Title:') !!}

你应该传递两个字符串而不是一个数组。