如何將重定向的兩個不同類型的$ errors集合傳遞迴同一頁面。我遇到的問題是與variationErrors變量,錯誤的是未定義的變量:variationErrors發生這種情況我葉片視圖頁面上將兩組錯誤傳遞到頁面laravel未定義變量
控制器:
$variations = Input::get("variations");
$variationErrors = [];
// dd($variations);
foreach ($variations as $id) {
$data = [
'producttype' => Input::get('producttype_' . $id),
'price' => Input::get('price_' . $id),
'quantity' => Input::get('quantity_' . $id),
'discount' => Input::get('discount_' . $id)
];
$validationVariations = Validator::make(
$data,
ProductVariations::$rules,
ProductVariations::$rulesMessages
);
if($validationVariations->fails()) {
$variationsHasErrors = true;
$variationErrors[$id] = $validationVariations->messages()->toArray();
}
}
if($validationProduct->fails() OR $variationsHasErrors) {
// problem here passing $variationErrors on blade page undefined $variationErrors
return Redirect::back()->withErrors($validationProduct, $variationErrors)->withInput(); // ->with(compact('productsVariations'));
}
頁:
{{ var_dump($variationErrors) }}
什麼版本的Laravel? – 2014-10-06 07:43:38