Laravel:表单动作和路由错误。缺少[Route:] [URI:{id}]的必需参数

时间:2018-06-21 03:31:46

标签: laravel-5

URL:http://drpinoy.me/1

控制器

public function show($id) {
    $fields = Field::all();
    $doctor = DB::table('doctors')->where('id', '=', $id)->first();
    return view('frontend.pages.single')
        ->with('fields', $fields)
        ->with('doctor', $doctor);
}
public function reviews(Request $request,$id) {
    return 'hello';
}

single.blade.php

<div class="reviews">
    {!! Form::open(['action'=>['FrontendController@reviews', $doctor->id], 'method'=>'POST']) !!}
        <div class="form-group">
            {{ Form::label('name', 'Full Name') }}
            {{ Form::text('name', '', ['class' => 'form-control', 'id' => 'name', 'placeholder' => 'Full Name']) }}
        </div> 
        <div class="form-group">
                {{ Form::label('email', 'Email Address') }}
                {{ Form::text('email', '', ['class' => 'form-control', 'id' => 'email', 'placeholder' => 'Email Address']) }}
            </div>   
        <div class="form-group">
            {{ Form::label('message', 'Message') }}
            {{ Form::message('message', '', ['class' => 'form-control', 'id' => 'achievements', 'placeholder' => 'Message']) }}
        </div>
        {{Form::submit('Submit', ['id' => 'submit', 'class' => 'btn btn-primary'])}}
    {!! Form::close() !!}
</div>

路线:

Route::get('/{id}', 'FrontendController@show');
Route::post('/{id}', 'FrontendController@reviews');

问候,我需要帮助,我只有一个网址为url drpinoy.me/1的页面,我在该页面中添加了一个表格,但无法通过路线错误。我是新手,需要建议。非常感谢你。.

1 个答案:

答案 0 :(得分:0)

首先添加一个静态ID,然后尝试提交表单,因为刀片中没有消息选项,因此在表单上删除消息存在一个问题

{{ Form::message('message', '', ['class' => 'form-control', 'id' => 'achievements', 'placeholder' => 'Message']) }}

将此消息替换为文本

{{ Form::text('message', '', ['class' => 'form-control', 'id' => 'achievements', 'placeholder' => 'Message']) }}