Trying to update the fields using Form Model Binding, but I am stuck as the following error got displayed:
ErrorException in HtmlBuilder.php line 431: Array to string conversion (View: C:\xampp\htdocs\cms\resources\views\posts\edit.blade.php)
Edit.blade.php
{!! Form::model($post, ['method'=>'PUT', ['action'=>'PostsController@update', $post->id]]) !!}
{{ csrf_field() }}
{!! Form::label('title', 'Title: ') !!}
{!! Form::text('title', null) !!}
{!! Form::submit('Update Post') !!}
{!! Form::close() !!}
Htmlbuilder.php [Line 430-432]
if (! is_null($value)) {
return $key . '="' . e($value) . '"';
}
I have tried numerous solutions but got no success. I don't know where the problem is.
答案 0 :(得分:2)
尝试将代码作为关联数组发送的代码:['method' => value, 'action' => value]
但不是混合['method' => value, ['action' => value]]
{!! Form::model($post, ['method'=>'POST', 'action'=>['PostsController@update', $post->id]]) !!}
答案 1 :(得分:1)
You are missing some brackets. The value of action
should be an array.
Try the following (write in a single line):
{!! Form::model($post,
['method'=>'PUT', 'action'=>
[ 'PostsController@update', $post->id]
])
!!}