【发布时间】:2018-06-23 05:44:51
【问题描述】:
我正在尝试创建一个通过 get 将数据传递到控制器的表单,但 URL 看起来总是这样:
但我想要这样的东西:
http://example.com/test/param1=horse/param2=cat/param3=dog
或
http://example.com/test/horse/cat/dog
路线:
Route::get('test/{param1}/{param2}/{param3}', ['as' => 'test', 'uses' => 'MainController@test']);
HTML:
<form action="{{ route('test') }}" method="get">
{{ csrf_field() }}
<div class="col-md-3">
<div class="form-group">
<label for="animal1">animal1</label>
<br>
<input type="text" name="animal1" class="form-control">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="animal2">animal2</label>
<input type="text" name="animal2" class="form-control">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="animal3>animal3</label>
<input type="text" name="animal3" class="form-control">
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>
问题是测试路由每 10 秒重新加载一次。因此,表单值必须在 URL 中,以便我可以在控制器中正确处理它们。
我在这里找到了这个问题,但没有太大帮助
How To Pass GET Parameters To Laravel From With GET Method ?
感谢您的帮助!
【问题讨论】: