creazione pagina per modificare un determinato product (parte 133)
1 files added
2 files modified
| | |
| | | ]); |
| | | } |
| | | |
| | | public function edit(string $id) { |
| | | $product = $this->model->find($id); |
| | | if( $product == false ) { |
| | | throw new PageNotFoundException("Product not found"); |
| | | } |
| | | echo $this->viewer->render("shared/header.php", [ |
| | | "title"=> "Edit product" |
| | | ]); |
| | | echo $this->viewer->render("Products/edit.php", [ |
| | | "product"=> $product |
| | | ]); |
| | | } |
| | | |
| | | public function showPage(string $title, string $id, string $page) { |
| | | echo $title, " ", $id, " ", $page; |
| | | } |
New file |
| | |
| | | <body> |
| | | <h1>Edit Product</h1> |
| | | |
| | | <p><a href="/products/<?= $product["id"] ?>/show" >Cancel</a></p> |
| | | </body> |
| | | </html> |
| | |
| | | <body> |
| | | <h1><?= $product["name"] ?></h1> |
| | | <p><?= $product["description"] ?></p> |
| | | |
| | | <p><a href="/products/<?= $product["id"] ?>/edit" >Edit</a></p> |
| | | </body> |
| | | |
| | | </html> |