【发布时间】:2017-07-05 13:57:53
【问题描述】:
我想使用一个表单中只有一个字段的值和两个字段作为控制器的路由参数。到目前为止,我实现的只是附加到 url 的一堆查询字符串参数。
我的表格:
{{ Form::open(['route' => ['anuncio.especificar_tipo_imovel', $valorCep = 'valorCEp'], 'method' => 'GET']) }}
<input type="hidden" value="14405024" id="valorCep" name="valorCep"/>
<label for="tbCep"/>
<input autocomplete="off" id="tbCep" style="width:400px;" name="cep" type="text" />
</label>
<input type="submit" value="continuar">
{{ Form::close() }}
我有这样的路线:
Route::get('anuncio/especificar_tipo_imovel/{valorCep}', [
'as' => 'anuncio.especificar_tipo_imovel',
'uses' => 'AnuncioController@especificar_tipo_imovel'
]);
还有这样的动作方法
public function especificar_tipo_imovel(Request $request, $valorCep)
{
return view('especificar_tipo_imovel');
}
我要发送的值是隐藏字段的值:valorCep
我想要一个像
http://my_route/34834839
由隐藏字段的值和$valorCep 路由参数组成的数字。
我的网址是这样的:
http://my_route/valorCEp?valorCep=14405024&cep=Rua++jardim+pedreiras14405024
【问题讨论】:
-
$xxxx=$request->valorCep;你可以这样使用
-
我的问题是没有在控制器中获取值。我的问题是 url 格式。
-
抱歉,没有得到您想要的??
-
我的问题的最后一行在我提交表单时显示我的网址。我想要一个以这种方式格式化的 url my_route/valorCep.I 只看到人们通过直接输入 url 来使用路由参数,我想知道如何以编程方式传递参数。我想要一个类似于 stackoverflow 的 url :)。
标签: php laravel model-view-controller