我正在尝试向幼虫提交表格。但是,我面临一个奇怪的问题,即表单提交时没有任何数据。当我尝试在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
我的route:list