Laravel表格不发送任何数据

时间:2019-09-07 08:00:29

标签: php laravel

我正在尝试向幼虫提交表格。但是,我面临一个奇怪的问题,即表单提交时没有任何数据。当我尝试在cotroller上print_r时显示:

Array
(
)

我的表单如下:

<form method="POST" action="{{route('amenityFront.index')}}" id="buildingByProperty">
    @csrf
    <select class="form-control" name="property" id="propertySelect">
        @foreach($properties as $pk => $pv)
            <option value="{{$pv->id}}" {{ ($pv->id == $selectedProperty)?'selected':'' }}>{{$pv->property_name}}</option>
        @endforeach
    </select>
    <button type="submit">Submit</button>
</form>

这是我的路线。是因为那条比赛路线吗?我是第一次使用此比赛路线。

路线:

    Route::match(['get', 'post'],'/', ['as' => 'amenityFront.index', 'uses' => 'AmenityController@index']);

更新:

我已将表格更新为:

<form method="POST" action="{{route('amenityFront.postIndex')}}" id="buildingByProperty">
    @csrf
    <select class="form-control" name="property" id="propertySelect">
        @foreach($properties as $pk => $pv)
            <option value="{{$pv->id}}" {{ ($pv->id == $selectedProperty)?'selected':'' }}>{{$pv->property_name}}</option>
        @endforeach
    </select>
    <button type="submit">Submit</button>
</form>

以及更新的路线:

Route::get('/', ['as' => 'amenityFront.index', 'uses' => 'AmenityController@index']);
    Route::post('/', ['as' => 'amenityFront.postIndex', 'uses' => 'AmenityController@postIndex']);

但是,我仍然没有发布到@index

,而不是重定向到postIndex

我的route:list

enter image description here

0 个答案:

没有答案