Fix site contact form field bindings

This commit is contained in:
MatthieuTD
2025-09-25 14:57:29 +02:00
parent 041478e9d4
commit f9de94907b

View File

@@ -5,7 +5,7 @@
<span class="label-text">Nom du contact</span> <span class="label-text">Nom du contact</span>
</label> </label>
<input <input
v-model="form.contactName" v-model="contactName"
type="text" type="text"
placeholder="Nom et prénom" placeholder="Nom et prénom"
class="input input-bordered" class="input input-bordered"
@@ -13,14 +13,14 @@
/> />
</div> </div>
<FieldPhone v-model="form.contactPhone" required /> <FieldPhone v-model="contactPhone" required />
<div class="form-control"> <div class="form-control">
<label class="label"> <label class="label">
<span class="label-text">Adresse</span> <span class="label-text">Adresse</span>
</label> </label>
<input <input
v-model="form.contactAddress" v-model="contactAddress"
type="text" type="text"
placeholder="Adresse complète" placeholder="Adresse complète"
class="input input-bordered" class="input input-bordered"
@@ -34,7 +34,7 @@
<span class="label-text">Code postal</span> <span class="label-text">Code postal</span>
</label> </label>
<input <input
v-model="form.contactPostalCode" v-model="contactPostalCode"
type="text" type="text"
placeholder="Code postal" placeholder="Code postal"
class="input input-bordered" class="input input-bordered"
@@ -47,7 +47,7 @@
<span class="label-text">Ville</span> <span class="label-text">Ville</span>
</label> </label>
<input <input
v-model="form.contactCity" v-model="contactCity"
type="text" type="text"
placeholder="Ville" placeholder="Ville"
class="input input-bordered" class="input input-bordered"
@@ -59,7 +59,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { toRefs } from 'vue' import { computed, toRef } from 'vue'
import type { PropType } from 'vue' import type { PropType } from 'vue'
import FieldPhone from '~/components/form/FieldPhone.vue' import FieldPhone from '~/components/form/FieldPhone.vue'
@@ -79,7 +79,42 @@ const props = defineProps({
}, },
}) })
const form = toRefs(props.form) const form = toRef(props, 'form')
const contactName = computed({
get: () => form.value.contactName,
set: (value: string) => {
form.value.contactName = value
},
})
const contactPhone = computed({
get: () => form.value.contactPhone,
set: (value: string) => {
form.value.contactPhone = value
},
})
const contactAddress = computed({
get: () => form.value.contactAddress,
set: (value: string) => {
form.value.contactAddress = value
},
})
const contactPostalCode = computed({
get: () => form.value.contactPostalCode,
set: (value: string) => {
form.value.contactPostalCode = value
},
})
const contactCity = computed({
get: () => form.value.contactCity,
set: (value: string) => {
form.value.contactCity = value
},
})
</script> </script>
<!-- <!--