Modified Checkbox Updates on Course re-select
This commit is contained in:
@@ -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,9 +41,9 @@ 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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user