Fix Form Display
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import RitzenbergenLib from "../../ritzenbergenlib";
|
import RitzenbergenLib from "../../ritzenbergenlib";
|
||||||
import FormResults from "../FormResults.vue";
|
import FormResults from "../FormResults.vue";
|
||||||
import { ref, defineProps } from "vue";
|
import { ref } from "vue";
|
||||||
import Modal from "../Modal.vue";
|
import Modal from "../Modal.vue";
|
||||||
import { Formular } from "../../dto/formular.dto";
|
import { Formular } from "../../dto/formular.dto";
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
forms.value=await RitzenbergenLib.graphqlClient.request<Formular[]>(`
|
forms.value=await RitzenbergenLib.graphqlClient.request<{formulare: Formular[] }>(`
|
||||||
{
|
{
|
||||||
formulare {
|
formulare {
|
||||||
id
|
id
|
||||||
@@ -15,7 +15,6 @@ async function init() {
|
|||||||
ispublic
|
ispublic
|
||||||
fields {
|
fields {
|
||||||
id
|
id
|
||||||
formular
|
|
||||||
name
|
name
|
||||||
displayname
|
displayname
|
||||||
displayvalue
|
displayvalue
|
||||||
@@ -32,7 +31,9 @@ async function init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
);
|
).then(data=>data.formulare);
|
||||||
|
|
||||||
|
console.log(forms.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const forms = ref([] as Formular[]);
|
const forms = ref([] as Formular[]);
|
||||||
@@ -51,16 +52,13 @@ function submit($event: Event) {
|
|||||||
const url = new URL(
|
const url = new URL(
|
||||||
RitzenbergenLib.RitzenbergenLib.api("/formulare/submit.php")
|
RitzenbergenLib.RitzenbergenLib.api("/formulare/submit.php")
|
||||||
);
|
);
|
||||||
const formData = new FormData($event.target);
|
const formData = new FormData(<HTMLFormElement>$event.target);
|
||||||
fetch(url.toString(), {
|
fetch(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData
|
body: formData
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
forms.value = Formular.getForms().then((f) => {
|
init();
|
||||||
forms.value = f;
|
values.value={};
|
||||||
});
|
|
||||||
|
|
||||||
values.value={};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +79,7 @@ const values=ref({});
|
|||||||
</Modal>
|
</Modal>
|
||||||
<section ref="anmeldeformular" id="anmeldeformular">
|
<section ref="anmeldeformular" id="anmeldeformular">
|
||||||
<section class="form5 cid-u6k7q0BfGa">
|
<section class="form5 cid-u6k7q0BfGa">
|
||||||
<div class="container" v-for="(form, i) in forms.filter((form)=>form.id==props.formid||props.id==null)" :key="form">
|
<div class="container" v-for="(form, i) in forms" :key="i">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 content-head">
|
<div class="col-12 content-head">
|
||||||
<div class="mbr-section-head mb-5">
|
<div class="mbr-section-head mb-5">
|
||||||
@@ -111,7 +109,7 @@ const values=ref({});
|
|||||||
:data-i="i"
|
:data-i="i"
|
||||||
@submit.prevent="submit"
|
@submit.prevent="submit"
|
||||||
>
|
>
|
||||||
<div v-for="(field, j) in form.fields" :key="field">
|
<div v-for="(field, j) in form.fields" :key="j">
|
||||||
<label
|
<label
|
||||||
v-if="field.placeholder == null"
|
v-if="field.placeholder == null"
|
||||||
:for="'field-' + field.id"
|
:for="'field-' + field.id"
|
||||||
|
|||||||
Reference in New Issue
Block a user