teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

エラーメッセージとPOSTしたデータを埋め込みできません。

2018/01/20 05:37

投稿

hidepon
hidepon

スコア206

title CHANGED
File without changes
body CHANGED
@@ -69,4 +69,14 @@
69
69
  この解決方法についていろいろと調べているのですが、
70
70
  解決方法が見つかりません。
71
71
  ご存知の方がいらっしゃいましたら、教えていただけるでしょうか?
72
+ 宜しくお願いいたします。
73
+   ※自己解決しました
74
+     route に
75
+ Route::get('/input_error', 'Contact@input_error');
76
+
77
+ (追記)
78
+ POST送信したデータならびにエラーメッセージが表示されません。
79
+ Undefined variable: name
80
+ return redirect('/input_error')->withErrors($validator)->withInput();
81
+ でエラーメッセージと入力データが送信されると思うのですが、違うのでしょうか?
72
82
  宜しくお願いいたします。

3

エラー内容を追記しました。

2018/01/20 05:37

投稿

hidepon
hidepon

スコア206

title CHANGED
File without changes
body CHANGED
@@ -60,4 +60,13 @@
60
60
  現時点のエラーは
61
61
  「Call to undefined method Illuminate\Support\Facades\Request::all()」となっています。
62
62
  いろいろ調べながらやっていますが、うまくいかず悩んでいます。
63
+ 宜しくお願いいたします。
64
+
65
+ (追記)
66
+ input_errorにリダイレクトができたのですが、
67
+ 今度は
68
+ 「MethodNotAllowedHttpException」というエラーが発生しています。
69
+ この解決方法についていろいろと調べているのですが、
70
+ 解決方法が見つかりません。
71
+ ご存知の方がいらっしゃいましたら、教えていただけるでしょうか?
63
72
  宜しくお願いいたします。

2

変数名の間違いがありました、

2018/01/20 03:49

投稿

hidepon
hidepon

スコア206

title CHANGED
File without changes
body CHANGED
@@ -34,7 +34,7 @@
34
34
  'contents'=>'required|max:10',
35
35
  ]);
36
36
  //if fails
37
- if($validation->fails())
37
+ if($validator->fails())
38
38
  {
39
39
  return redirect('/input_error')->withErrors($validator)->withInput();
40
40
  }

1

ドキュメントに沿ってFailの部分を修正しました。

2018/01/20 03:34

投稿

hidepon
hidepon

スコア206

title CHANGED
File without changes
body CHANGED
@@ -36,7 +36,7 @@
36
36
  //if fails
37
37
  if($validation->fails())
38
38
  {
39
- return redirect("/input_error")->back()->withErrors($validation->errors())->withInput();
39
+ return redirect('/input_error')->withErrors($validator)->withInput();
40
40
  }
41
41
  $name = Request::input('name');
42
42
  $email = Request::input('email');