]> git.agnieray.net Git - galette.git/commitdiff
Errors were not flashed
authorJohan Cwiklinski <johan@x-tnd.be>
Mon, 15 Jun 2020 05:54:41 +0000 (07:54 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Mon, 15 Jun 2020 05:54:41 +0000 (07:54 +0200)
galette/lib/Galette/Controllers/PdfController.php

index 172442bb8b2998c5d984e8631c546d9ddaff30a3..966de17878783443a51266de87b408e5cb800355 100644 (file)
@@ -585,11 +585,9 @@ class PdfController extends AbstractController
             $type = (int)$post['model_type'];
         }
 
+        $error_detected = [];
         if ($type === null) {
-            $this->flash->addMessage(
-                'error_detected',
-                _T("Missing PDF model type!")
-            );
+            $error_detected[] = _T("Missing PDF model type!");
         } else {
             $class = PdfModel::getTypeClass($type);
             if (isset($post[PdfModel::PK])) {
@@ -621,16 +619,22 @@ class PdfController extends AbstractController
                         _T("Model has been successfully stored!")
                     );
                 } else {
-                    $this->flash->addMessage(
-                        'error_detected',
-                        _T("Model has not been stored :(")
-                    );
+                    $error_detected[] = _T("Model has not been stored :(");
                 }
             } catch (\Exception $e) {
                 $error_detected[] = $e->getMessage();
             }
         }
 
+        if (count($error_detected) > 0) {
+            foreach ($error_detected as $error) {
+                $this->flash->addMessage(
+                    'error_detected',
+                    $error
+                );
+            }
+        }
+
         return $response
             ->withStatus(301)
             ->withHeader('Location', $this->router->pathFor('pdfModels', ['id' => $model->id]));