Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

105 wiersze
4.9KB

  1. <script>
  2. window.__campaignTypes = <?= json_encode($model->campaignTypes, JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  3. window.__initialTypeId = <?= json_encode($model->form['campaign_type_id'], JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  4. window.__initialValues = <?= json_encode($model->form['attribute_values'], JSON_HEX_TAG | JSON_THROW_ON_ERROR) ?>;
  5. </script>
  6. <section class="content-stack">
  7. <div class="page-toolbar">
  8. <div class="section-heading">
  9. <h1><?= e($model->title) ?></h1>
  10. <p>Choose a campaign type, enter a name, then fill in the type&rsquo;s attribute values.</p>
  11. </div>
  12. <a class="button button-secondary" href="/campaigns">&larr; Back to list</a>
  13. </div>
  14. <?php if (!$model->campaignTypes): ?>
  15. <div class="alert alert-error">
  16. No campaign types have been defined yet.
  17. <a href="/campaign-types/create">Create a campaign type</a> before adding campaigns.
  18. </div>
  19. <?php else: ?>
  20. <section class="section-panel" x-data="campaignForm(window.__campaignTypes, window.__initialTypeId, window.__initialValues)">
  21. <?php if (isset($model->errors['_token'])): ?>
  22. <div class="alert alert-error"><?= e($model->errors['_token'][0]) ?></div>
  23. <?php endif; ?>
  24. <form method="post" action="/campaigns" class="ct-form" novalidate>
  25. <?= csrf_field() ?>
  26. <div class="form-section">
  27. <label class="field field-full">
  28. <span>Campaign type <span class="required-mark">*</span></span>
  29. <select
  30. class="input<?= isset($model->errors['campaign_type_id']) ? ' input-error' : '' ?>"
  31. name="campaign_type_id"
  32. x-model="selectedTypeId"
  33. x-on:change="onTypeChange()"
  34. required
  35. >
  36. <option value="0">— Select a campaign type —</option>
  37. <?php foreach ($model->campaignTypes as $type): ?>
  38. <option
  39. value="<?= e((string) $type['id']) ?>"
  40. <?= (int) $model->form['campaign_type_id'] === $type['id'] ? 'selected' : '' ?>
  41. ><?= e($type['name']) ?></option>
  42. <?php endforeach; ?>
  43. </select>
  44. <?php if (isset($model->errors['campaign_type_id'])): ?>
  45. <small class="field-error"><?= e($model->errors['campaign_type_id'][0]) ?></small>
  46. <?php endif; ?>
  47. </label>
  48. </div>
  49. <div class="form-section" x-show="currentAttributes.length > 0">
  50. <div class="attributes-header">
  51. <h3>Attribute values</h3>
  52. <p class="attributes-hint">Fields defined by the selected campaign type.</p>
  53. </div>
  54. <div class="form-grid">
  55. <template x-for="attr in currentAttributes" :key="attr.name">
  56. <label class="field">
  57. <span x-text="attr.name"></span>
  58. <template x-if="attr.type === 'boolean'">
  59. <select class="input"
  60. :name="`attribute_values[${attr.name}]`"
  61. x-on:change="attributeValues[attr.name] = $event.target.value">
  62. <option value="" :selected="!attributeValues[attr.name]">— Select —</option>
  63. <option value="true" :selected="attributeValues[attr.name] === 'true'">True</option>
  64. <option value="false" :selected="attributeValues[attr.name] === 'false'">False</option>
  65. </select>
  66. </template>
  67. <template x-if="attr.type !== 'boolean'">
  68. <input class="input"
  69. :type="inputType(attr.type)"
  70. :name="`attribute_values[${attr.name}]`"
  71. :value="attributeValues[attr.name] ?? ''"
  72. x-on:input="attributeValues[attr.name] = $event.target.value">
  73. </template>
  74. </label>
  75. </template>
  76. </div>
  77. </div>
  78. <p class="attributes-hint" x-show="selectedTypeId && currentAttributes.length === 0">
  79. This campaign type has no attributes defined.
  80. </p>
  81. <div class="form-actions">
  82. <button class="button button-primary" type="submit">Save Campaign</button>
  83. <a class="button button-secondary" href="/campaigns">Cancel</a>
  84. </div>
  85. </form>
  86. </section>
  87. <?php endif; ?>
  88. </section>

Powered by TurnKey Linux.