diff --git a/ui/src/components/trainingReport/trainingReportForm.vue b/ui/src/components/trainingReport/trainingReportForm.vue index dae28db..e224edf 100644 --- a/ui/src/components/trainingReport/trainingReportForm.vue +++ b/ui/src/components/trainingReport/trainingReportForm.vue @@ -6,6 +6,7 @@ import { toTypedSchema } from '@vee-validate/zod' import { computed, onMounted, ref, watch } from 'vue' import { getAllAttendeeRoles, getAllTrainings, postTrainingReport } from '@/api/trainingReport' import { getMembers, Member } from '@/api/member' + import FieldGroup from '../ui/field/FieldGroup.vue' import Field from '../ui/field/Field.vue' import FieldLabel from '../ui/field/FieldLabel.vue' @@ -18,7 +19,8 @@ import FieldLegend from '../ui/field/FieldLegend.vue' import FieldDescription from '../ui/field/FieldDescription.vue' import Checkbox from '../ui/checkbox/Checkbox.vue' -const { handleSubmit, resetForm, errors, values } = useForm({ + +const { handleSubmit, resetForm, errors, values, setFieldValue } = useForm({ validationSchema: toTypedSchema(trainingReportSchema), initialValues: { course_id: null, @@ -39,10 +41,10 @@ watch(values, (newErrors) => { watch(() => values.course_id, (newCourseId, oldCourseId) => { if (!oldCourseId) return; - values.attendees.forEach(a => { - a.passed_bookwork = false; - a.passed_qual = false; - }); + values.attendees.forEach((a, index) => { + setFieldValue(`attendees[${index}].passed_bookwork`, false); + setFieldValue(`attendees[${index}].passed_qual`, false); + }); }); const submitForm = handleSubmit(onSubmit);