From 739d6166ca5ce89d91483ca77eaf14b63d16805d Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Wed, 22 May 2024 11:25:15 +0200 Subject: [PATCH] correzione e visualizzazione errore direttamente tramite form (parte 129) --- src/App/Controllers/products.php | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index 0165711..bf0a304 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -43,8 +43,16 @@ "description" => empty($_POST["description"]) ? null : $_POST["description"] ]; - var_dump($this->model->insert($data)); - - print_r($this->model->getErrors()); + if($this->model->insert($data)) { + echo "record saved"; + } else { + echo $this->viewer->render("shared/header.php", [ + "title" => "New Product" + ]); + + echo $this->viewer->render("Products/new.php", + ["errors" => $this->model->getErrors() + ]); + }; } } \ No newline at end of file -- Gitblit v1.8.0