Fixed checkbox reset not updating visually
This commit is contained in:
@@ -31,20 +31,20 @@ const { handleSubmit, resetForm, errors, values, setFieldValue } = useForm({
|
||||
})
|
||||
|
||||
watch(errors, (newErrors) => {
|
||||
console.log(newErrors)
|
||||
console.log(newErrors)
|
||||
}, { deep: true })
|
||||
|
||||
watch(values, (newErrors) => {
|
||||
console.log(newErrors.attendees)
|
||||
console.log(newErrors.attendees)
|
||||
}, { deep: true })
|
||||
|
||||
watch(() => values.course_id, (newCourseId, oldCourseId) => {
|
||||
if (!oldCourseId) return;
|
||||
|
||||
values.attendees.forEach((a, index) => {
|
||||
setFieldValue(`attendees[${index}].passed_bookwork`, false);
|
||||
setFieldValue(`attendees[${index}].passed_qual`, false);
|
||||
});
|
||||
values.attendees.forEach((a, index) => {
|
||||
setFieldValue(`attendees[${index}].passed_bookwork`, false);
|
||||
setFieldValue(`attendees[${index}].passed_qual`, false);
|
||||
});
|
||||
});
|
||||
|
||||
const submitForm = handleSubmit(onSubmit);
|
||||
@@ -189,7 +189,8 @@ onMounted(async () => {
|
||||
<div class="relative inline-flex items-center group">
|
||||
|
||||
<Checkbox :disabled="!selectedCourse?.hasBookwork"
|
||||
:name="`attendees[${index}].passed_bookwork`" v-bind="field">
|
||||
:name="`attendees[${index}].passed_bookwork`" :model-value="!field.checked"
|
||||
@update:model-value="field['onUpdate:modelValue']">
|
||||
</Checkbox>
|
||||
<!-- Tooltip bubble -->
|
||||
<div v-if="!selectedCourse?.hasBookwork" class="pointer-events-none absolute -top-9 left-1/2 -translate-x-1/2
|
||||
@@ -212,7 +213,8 @@ onMounted(async () => {
|
||||
<div class="flex flex-col items-center">
|
||||
<div class="relative inline-flex items-center group">
|
||||
<Checkbox :disabled="!selectedCourse?.hasQual"
|
||||
:name="`attendees[${index}].passed_qual`" v-bind="field"></Checkbox>
|
||||
:name="`attendees[${index}].passed_qual`" :model-value="!field.checked"
|
||||
@update:model-value="field['onUpdate:modelValue']"></Checkbox>
|
||||
<!-- Tooltip bubble -->
|
||||
<div v-if="!selectedCourse?.hasQual" class="pointer-events-none absolute -top-9 left-1/2 -translate-x-1/2
|
||||
whitespace-nowrap rounded-md bg-popover px-2 py-1 text-xs
|
||||
|
||||
Reference in New Issue
Block a user