发布评论写表格动作
<form method="post" action="{{url('posts/{{$post->id}}/comments') }}">
{{ csrf_field() }}
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Comment *</label>
<textarea maxlength="5000" rows="10" class="form-control" name="body" id="body" placeholder="here will be your comment"></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="submit" value="Post Comment" class="btn btn-primary btn-lg" data-loading-text="Loading...">
</div>
</div>
</form>
和路线代码是
Route::post('posts/{post}/comments','CommentController@store');
但问题是它何时显示错误 解析错误:语法错误,意外&#39;}&#39;,期待&#39;,&#39;或者&#39;)&#39; (视图: 显示错误行是
<form method="post" action="{{url('posts/{{$post->id}}/comments') }}">
那么我在这行中的错误在哪里?怎么解决呢?
答案 0 :(得分:2)
您不能在另一个刀片指令中使用刀片指令,您必须在字符串中连接变量。像这样:
<form method="post" action="{{ url('posts/' . $post->id . '/comments') }}">
答案 1 :(得分:1)
将此行更改为:
<form method="post" action="{{ url('posts/'.$post->id.'/comments') }}">