2013-04-06 76 views
3

錯誤,如果我的驗證失敗,我這樣做:Laravel秀鑑於

return Redirect::back()->with('validation', $validation->errors->all()); 

也是我使用:

$restful = true; 

所以當我在get_edit() - 我'得到一個錯誤,有當生成我的視圖時,沒有$驗證變量,當在post_edit() - 其一切正常,因爲它的返回錯誤的重定向...

這是我的看法:

<? foreach($validation as $e): ?> 

<div><?= $e; ?></div> 

<? endforeach; ?> 

不確定的變量$驗證,現在我'試圖把它放在路由器::之前

Route::filter('before', function() 
{ 
    View::share('validation', array()); 
}); 

所以變量存在,但是是空的,但現在出現後,一個新的問題,每次這個過濾器執行它會覆蓋那些生成我的post_edit()$validation,在我看來,我也看到了一個變量$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 

} 
+0

請幫忙!!!!! – Hello 2013-04-06 13:47:35

回答