aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/forms/form.php24
-rw-r--r--templates/vue-app.php9
2 files changed, 31 insertions, 2 deletions
diff --git a/templates/forms/form.php b/templates/forms/form.php
index fe19404..b6406d0 100644
--- a/templates/forms/form.php
+++ b/templates/forms/form.php
@@ -19,7 +19,29 @@ foreach ($allinputs as $input) {
}
}
$form_id = md5(uniqid());
-?><form v-cloak
+
+$vueApp = Studip\VueApp::create('StudipForm');
+foreach ($form->getParts() as $index => $part) {
+ $vueApp->withSlot('part' . $index, $part->renderWithCondition());
+}
+echo $vueApp->withProps([
+ 'form'=> [
+ 'autosave' => $form->isAutoStoring(),
+ 'values' => $inputs,
+ 'required' => $required_inputs,
+ 'serverValidation' => $server_validation,
+ 'url' => $form->getURL() ?? false,
+ ],
+
+ 'debug-mode' => $form->getDebugMode(),
+ 'is-collapsable' => $form->isCollapsable(),
+ 'is-secure' => $form->getDataSecure(),
+ 'request-url' => $_SERVER['REQUEST_URI'],
+ 'slots' => array_keys($vueApp->getSlots()),
+]);
+?>
+
+<form v-cloak
method="post"
<? if (!$form->isAutoStoring()) : ?>
action="<?= htmlReady($form->getURL()) ?>"
diff --git a/templates/vue-app.php b/templates/vue-app.php
index 2c34929..95a228e 100644
--- a/templates/vue-app.php
+++ b/templates/vue-app.php
@@ -3,6 +3,7 @@
* @var array $attributes
* @var string $baseComponent
* @var array $props
+ * @var array $slots
* @var array $storeData
*/
?>
@@ -10,5 +11,11 @@
<script type="application/json" id="vue-store-data-<?= htmlReady($store) ?>"><?= json_encode($data) ?></script>
<? endforeach; ?>
<div <?= arrayToHtmlAttributes($attributes) ?>>
- <<?= strtokebabcase($baseComponent) ?> <?= arrayToHtmlAttributes($props) ?>/>
+ <<?= strtokebabcase($baseComponent) ?> <?= arrayToHtmlAttributes($props) ?>>
+ <? foreach ($slots as $name => $slot): ?>
+ <template #<?= htmlReady($name) ?>>
+ <?= $slot ?>
+ </template>
+ <? endforeach; ?>
+ </<?= strtokebabcase($baseComponent) ?>>
</div>