私の検証が失敗した場合、私はこれを行います:
return Redirect::back()->with('validation', $validation->errors->all());
また、私は使用しています:
$restful = true;
そのため、オンのとき-get_edit()
ビューを生成するときに$validation変数がないというエラーが表示されます-インの場合post_edit()
-エラーのあるリダイレクトが返されるため、すべて問題ありません...
これは私の見解です:
<? foreach($validation as $e): ?>
<div><?= $e; ?></div>
<? endforeach; ?>
未定義の変数 $validation、今は Router::before に配置しようとしています
Route::filter('before', function()
{
View::share('validation', array());
});
したがって、変数は存在しますが空ですが、新しい問題が発生します。このフィルターが実行されるたびに、 my を生成するものをオーバーライドし$validation
ます。 、 手伝って頂けますか?post_edit()
$errors
すぐに私の問題は次のとおりです。
public function get_edit($id)
{
//generate my view with all nessesary data, but i can't generate here an error variable
// or its better to put it in one place to globally share it in the views, otherwise i am //getting an error
}
public function post_edit($id)
{
//validating $_POST data, if there is an error redirect it back to the get_edit() WITH a //variable containing errors
}