【发布时间】:2017-02-17 09:58:34
【问题描述】:
我在 laravel 中的路由参数有问题, 这是 main.blade.php :
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
Generate Your Domain Now
</div>
{!! Form::open(['route'=>'generatorindex' , 'method' => 'post']) !!}
<input type="hidden" name="_token" value="{!! csrf_token() !!}">
<input name="inputkeyword" type="text" placeholder="Enter your keyword">
<button type="submit" value="Generate"></button>
{!! Form::close() !!}
</div>
</div>
</body>
这是控制器中的功能:
public function generator(Request $inputkeyword)
{
echo $productname = $inputkeyword->input('inputkeyword');
}
最后,这是路线:
Route::any('/generator/{inputkeyword}', [ 'as' => 'generatorindex', 'uses' => 'MainController@generator' ]);
但它会返回:
ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: generatorindex] [URI: generator/{inputkeyword}]. (View: C:\Users\Mostafa\myapp\resources\views\main.blade.php)
我做错了什么?我应该在哪里定义 inputkeyword 参数?
【问题讨论】:
-
在路由中查看您已经像这样定义 /generator/{inputkeyword} 但在表单提交中您只传递了 generatorindex 所以请发送 generatorindex/parameter{id}
标签: php laravel laravel-5 laravel-5.2 laravel-5.4