我的问题似乎与Laravel助手。一切工作正常,直到我一些文件更改到其他文件夹,当然我改变了路线和路线上和控制器,但现在我得到这个消息:“htmlentities()期望参数1是字符串,数组给定”在PHP中
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)
这是我创建的文件:
<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 -->
这是我的控制文件:
<?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)
{
//
}
我会是你的帮助表示感谢。
你没有显示'HtmlBuilder .php第65行“,但在那里有一个到'htmlentities()'的调用,并且你正在传递一个数组。 – AbraCadaver
抱歉为,这是在该行65 HtmlBuilder.php 公共函数escapeAll($值) { 返回ヶ辆($值,ENT_QUOTES, 'UTF-8'); } –
所以你必须追查它。代码中的某些内容会调用其他最终调用'escapeAll()'的东西。在'htmlentities()'之前使用'debug_print_backtrace()'来查看它来自哪里。 – AbraCadaver