corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-23 85f6ec1bc8f094e769835e9836b9fab7fb9e6ace
output dei valori già esistenti per modificarli nella pagina edit (parte 134)
1 files added
2 files modified
27 ■■■■■ changed files
views/Products/edit.php 4 ●●●● patch | view | raw | blame | history
views/Products/form.php 11 ●●●●● patch | view | raw | blame | history
views/Products/new.php 12 ●●●●● patch | view | raw | blame | history
views/Products/edit.php
@@ -1,6 +1,10 @@
<body>
    <h1>Edit Product</h1>
    <form method="post" action="/products/<?= $product["id"]?>/update">
        <?php require "form.php"?>
    </form>
    <p><a href="/products/<?= $product["id"] ?>/show" >Cancel</a></p>
</body>
</html>
views/Products/form.php
New file
@@ -0,0 +1,11 @@
<label for="name">Name</label>
<input type="text", id="name", name="name" value="<?= $product["name"] ?? ""?>">
<?php if (isset($errors["name"])): ?>
            <p><?= $errors["name"] ?></p>
<?php endif; ?>
<label for="description">Description</label>
<textarea id="description", name="description"><?= $product["description"] ?? ""?></textarea>
<button>Save</button>
views/Products/new.php
@@ -1,17 +1,7 @@
<body>
    <h1>New product</h1>
    <form method="post" action="/products/create">
        <label for="name">Name</label>
        <input type="text", id="name", name="name">
        <?php if (isset($errors["name"])): ?>
            <p><?= $errors["name"] ?></p>
        <?php endif; ?>
        <label for="description">Description</label>
        <textarea id="description", name="description"></textarea>
        <button>Save</button>
        <?php require "form.php"?>
    </form>
</body>
</hmtl>