edit.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php use App\Utils\Url, App\Utils\Html ?>
  2. <?php $app->render('layouts/header', ['title' => 'Edit note']) ?>
  3. <?php $app->render('layouts/navbar', ['app' => $app]) ?>
  4. <h1>Edit note</h1>
  5. <?php $app->render('layouts/alerts/error', ['error' => $error]) ?>
  6. <?php $app->render('layouts/alerts/success', ['success' => $success]) ?>
  7. <div>
  8. <a href="<?= Url::build('notes') ?>">
  9. < Back
  10. </a>
  11. <a href="<?= Url::build(['notes', $note['id']]) ?>">
  12. View
  13. </a>
  14. </div>
  15. <form method="post" enctype="multipart/form-data" action="<?= Url::build(['notes', 'update', $note['id']]) ?>">
  16. <fieldset>
  17. <legend>Note editing</legend>
  18. <div class="form-group">
  19. <label for="title">
  20. Title:
  21. </label>
  22. <input
  23. type="text"
  24. id="title"
  25. name="title"
  26. placeholder="Enter note title"
  27. minlength="1"
  28. maxlength="255"
  29. required
  30. value="<?= Html::escape($note['title']) ?>">
  31. <small class="text-error"><?= Html::escape($validations['title']) ?></small>
  32. </div>
  33. <div class="form-group">
  34. <label for="body">
  35. Body (markdown):
  36. </label>
  37. <textarea
  38. id="textarea"
  39. name="body"
  40. placeholder="Enter note body"
  41. cols="30"
  42. rows="15"
  43. required
  44. minlength="1"
  45. maxlength="<?= pow(2, 16) - 1 ?>"><?= Html::simpleEscape($note['body']) ?></textarea>
  46. <small class="text-error"><?= Html::escape($validations['body']) ?></small>
  47. </div>
  48. <div class="form-group">
  49. <label for="tags">
  50. Tags:
  51. </label>
  52. <select id="tags" name="tags[]" multiple size="4">
  53. <?php foreach ($tags as $tag): ?>
  54. <option value="<?= Html::escape($tag['id']) ?>" <?= $tag['selected'] ? 'selected' : '' ?>>
  55. <?= Html::escape($tag['name']) ?>
  56. </option>
  57. <?php endforeach ?>
  58. </select>
  59. <?php if (is_array($validations['tags'])): ?>
  60. <?php foreach ($validations['tags'] as $key => $value): ?>
  61. <small class="text-error"><?= Html::escape($value) ?></small>
  62. <?php endforeach ?>
  63. <?php else: ?>
  64. <small class="text-error"><?= Html::escape($validations['tags']) ?></small>
  65. <?php endif ?>
  66. <small>*Hold down the <kbd>Ctrl</kbd> (Windows) or <kbd>Command</kbd> (Mac) button to select/deselect multiple options.</small>
  67. </div>
  68. <input type="hidden" name="csrf_token" value="<?= Html::escape($app->local('csrf_token') ?? null) ?>">
  69. <input type="submit" name="submit" value="Save" class="btn btn-default">
  70. </fieldset>
  71. </form>
  72. <?php $app->render('layouts/footer') ?>