2017-03-09 9 views
1

私の問題はLaravelヘルパーのようです。私は他のフォルダにいくつかのファイルを変更するまですべてが、罰金働いていた、もちろん私はルートを変更し、ルートとコントローラ上のが、今、私はこのメッセージを取得しています:"PHPでhtmlentities()は、パラメータ1が文字列で配列が必要です"

<div class="content"> 
    <div class="container-fluid"> 
     <div class="row well bs-component"> 
      <div class="col-md-8 col-md-offset"> 
      <div class="input-group"> 

       <h3 class="text-center">Crear Nueva Publicación</h3> 
       <hr> 

       {!! Form::open(array('route' => 'posts.store', 'data-parsley-validate' => '')) !!} 

        {{ Form::label('title', ' Título:', array('class' => 'fa fa-pencil')) }} 

        {{ Form::text('title', null, array('class' => 'form-control', 'required' => '', 'maxlength' => '255')) }} 

        {{ Form::label('body', ' Contenido:', array('class' => 'fa fa-pencil-square-o')) }} 

        {{ Form::textarea('body', null, array('class' => 'form-control', 'required' => '')) }} 

        {{ Form::submit('Publicar', array('class' => 'btn btn-info')) }} 


       </div> 
      </div> <!-- col-md-8 end --> 


      <div class="col-md-4"> 
      <div class="input-group"> 
       <h3 class="text-center">Categoría e imágen</h3> 
       <hr> 


        <br> <hr> 

        {{ Form::label('badge', ' Etiqueta:', array('class' => 'fa fa-tags')) }} 

        {{ Form::text('badge', array('class' => 'form-control', 'maxlength' => '20')) }} 
        <br> <hr> 

        {{ Form::label('postimg', ' Seleccionar Imagen', array('class' => 'fa fa-picture-o')) }} 
        <br> <br> 
        {{ Form::file('postimg', array('require' => '', 'maxlength' => '255')) }} 

       {!! Form::close() !!} 

      </div> <!-- item-group end --> 
      </div> <!-- col-md-4 end --> 


     </div> <!-- end of row --> 
    </div> <!-- end of container --> 
</div> <!-- end of content --> 

ErrorException in HtmlBuilder.php line 65: htmlentities() expects parameter 1 to be string, array given (View: /Library/WebServer/Documents/gamstec/resources/views/posts/create.blade.php)

これは私の作成したファイルです私はあなたの助けのために感謝するでしょう

<?php 


public function index() 
{ 
    return view('admin'); 
} 

/** 
* Show the form for creating a new resource. 
* 
* @return \Illuminate\Http\Response 
*/ 
public function create() 
{ 
    return view('posts.create'); 
} 

/** 
* Store a newly created resource in storage. 
* 
* @param \Illuminate\Http\Request $request 
* @return \Illuminate\Http\Response 
*/ 
public function store(Request $request) 
{ 
    // validate the data 
    $this->validate($request, array(
     'title' => 'required|max:255', 
     'body' => 'required', 
     )); 

    // store in database 
    $post = new Post; 

    $post->title = $request->title; 
    $post->body = $request->body; 
    $post->badge = $request->badge; 
    $post->postimg = $request->postimg; 

    $post->save(); 

    Session::flash('success', 'La publicación se ha creado correctamente'); 

    // redirect to another page 
    return redirect()->route('show', $post->id); 
} 

/** 
* Display the specified resource. 
* 
* @param int $id 
* @return \Illuminate\Http\Response 
*/ 
public function show($id) 
{ 
    $post = Post::find($id); 
    return view('show')->withPost($post); 
} 

/** 
* Show the form for editing the specified resource. 
* 
* @param int $id 
* @return \Illuminate\Http\Response 
*/ 
public function edit($id) 
{ 
    // 
} 

/** 
* Update the specified resource in storage. 
* 
* @param \Illuminate\Http\Request $request 
* @param int $id 
* @return \Illuminate\Http\Response 
*/ 
public function update(Request $request, $id) 
{ 
    // 
} 

/** 
* Remove the specified resource from storage. 
* 
* @param int $id 
* @return \Illuminate\Http\Response 
*/ 
public function destroy($id) 
{ 
    // 
} 

これは私のコントローラファイルです。

{{ Form::text('badge', array('class' => 'form-control', 'maxlength' => '20')) }} 

2番目の引数は、他の属性を追加するには、アレイ

することはできませんとあなたが付加価値オプションを渡すことができ、メソッドの3番目の引数を渡す:ラインエラーを生成します

+0

.php 65行目ですが、そこに 'htmlentities()'が呼び出されていて、それに配列を渡しています。 – AbraCadaver

+0

これは申し訳ありませんが、これは65行目のHtmlBuilder.phpです。 public function escapeAll($ value) { return htmlentities($ value、ENT_QUOTES、 'UTF-8'); } –

+0

これをトレースする必要があります。あなたのコード内の何かが、最終的に 'escapeAll()'を呼び出す何かを呼び出します。 'htmlentities()'の前に 'debug_print_backtrace()'を使ってどこから来たのかを確認します。 – AbraCadaver

答えて

2

。この3番目の引数は配列でなければなりません。これに

変更:

{{ Form::text('badge', '', array('class' => 'form-control', 'maxlength' => '20')) }} 
+0

ありがとう!それは魅力のように動作します! –

+0

フォームにエラーがある場合は、値をプレフィルするためにold( 'badge')の代わりにold( 'badge')を使用してください。 – Brett

+0

@JuanRincónこの回答があなたの質問を解決した場合は、下矢印のアウトラインチェックマークをクリックして受け入れてください。これは問題を「解決済み」とし、問題を解決するために時間を割いた回答者を表彰します。 – Daedalus

0

それはあなたのコード内でこの行です:

{{ Form::text('badge', array('class' => 'form-control', 'maxlength' => '20')) }} 

これが第2の値としてnull必要があります:あなたは `HtmlBuilderを示さなかった

{{ Form::text('badge', null, array('class' => 'form-control', 'maxlength' => '20')) }} 
+0

実際にこれも私のために働いてくれました –

関連する問題