new.php 2.4 KB

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