1
0

project_template_overrides_form.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <div class="container mt-3 py-4">
  2. <form method="post">
  3. <h3>Active Template Overrides</h3>
  4. <?php
  5. if(empty($template_overrides)) {
  6. ?>
  7. <div class="alert alert-info">There are no active template overrides for this project.</div>
  8. <?php
  9. }
  10. else {
  11. $fields = $template->getFields();
  12. ?>
  13. <table class="table table-bordered table-hover">
  14. <thead>
  15. <tr>
  16. <th>Field</th>
  17. <th>Element</th>
  18. <th>Value</th>
  19. <th>Action</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <?php
  24. foreach($template_overrides as $override) {
  25. ?>
  26. <tr>
  27. <td class="align-middle">
  28. <?=htmlspecialchars($fields[$override->field]->label)?>
  29. </td>
  30. <td class="align-middle">
  31. <?=ucfirst($override->element)?>
  32. </td>
  33. <td class="align-middle">
  34. <?=htmlspecialchars($override->value)?>
  35. </td>
  36. <td class="text-right">
  37. <button type="submit" name="delete" value="<?=htmlspecialchars($override->field)?>-<?=htmlspecialchars($override->element)?>" class="btn btn-sm btn-danger">Delete</button>
  38. </td>
  39. </tr>
  40. <?php
  41. }
  42. ?>
  43. </tbody>
  44. </table>
  45. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  46. <?php
  47. }
  48. ?>
  49. </form>
  50. <form method="post">
  51. <h3>Add Template Override</h3>
  52. <input type="hidden" name="add" value="1" />
  53. <div class="row mb-1">
  54. <label class="col-sm-4 col-form-label">
  55. Field
  56. </label>
  57. <div class="col-sm">
  58. <select class="form-control" name="field" required>
  59. <option value="">Select Field</option>
  60. <?php
  61. foreach($fields as $value => $field) {
  62. ?>
  63. <option value="<?=htmlspecialchars($field->name)?>"><?=htmlspecialchars($field->label)?></option>
  64. <?php
  65. }
  66. ?>
  67. </select>
  68. </div>
  69. </div>
  70. <div class="row mb-1">
  71. <label class="col-sm-4 col-form-label">
  72. Element
  73. </label>
  74. <div class="col-sm">
  75. <select class="form-control" name="element" required>
  76. <option value="label">Label</option>
  77. </select>
  78. </div>
  79. </div>
  80. <div class="row mb-1">
  81. <label class="col-sm-4 col-form-label">
  82. Value
  83. </label>
  84. <div class="col-sm">
  85. <input class="form-control" type="text" name="value" placeholder="Type override value" required />
  86. </div>
  87. </div>
  88. <div class="row">
  89. <div class="col-sm offset-sm-4">
  90. <button class="btn btn-primary" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">Add Override</button>
  91. </div>
  92. </div>
  93. </form>
  94. </div>