1
送信(Post)後にユーザーに以前入力したフォームを再度入力したいと思います。次の例は私のために働いていません。誰かが解決法またはより良い選択肢を推奨できますか?Laravel 5.5 - 送信後にフォームを再入力
[表示]
<input id="txtField" name="txtField" value="{{ old('txtField') }}"/>
<input type="submit" value="Submit">
[コントローラー]
public function showResults(){
$field = Request::input('txtField');
/* Note: "performQuery" is a private function
* that always returns a new view in the
* form: "view('some-view', compact('results'))" */
return $this->performQuery($field);
}
[ルート]
Route::get('/View','[email protected]');
Route::post('/View','[email protected]');
Laravel Collectiveフォームを試してください。以前はLaravelの機能として使用されていましたが、削除され、別のパッケージとして維持されています。 https://laravelcollective.com/docs/5.4/html – andrewtweber
ありがとうございます、@andrewtweber私はそれにショットを与える –
また、あなたのコントローラでは、ポストが失敗した後、あなたはページにリダイレクトしていますか?もしそうなら、おそらく 'redirect() - > withInput();'を呼び出す必要がありますので、古い入力が保持されます – andrewtweber