From e6795a02ef1a4bf76e3a7cb1ca2dcc6c6884d9f6 Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Mon, 24 Nov 2025 16:59:50 +0700 Subject: [PATCH] fix switch toggle on wording data parents --- app/components/app/person/family-parents-form.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/components/app/person/family-parents-form.vue b/app/components/app/person/family-parents-form.vue index 8c41a3c8..fddb5ecb 100644 --- a/app/components/app/person/family-parents-form.vue +++ b/app/components/app/person/family-parents-form.vue @@ -33,13 +33,14 @@ watch( (newValue) => { if (!formRef.value) return - const currentFamilies = formRef.value.values?.families || [] - if (newValue === '1') { isFamilyFormDisabled.value = false - // CREATE MODE — Auto default - if (!isEditing.value && currentFamilies.length === 0) { + const fam = formRef.value.values?.families || [] + + const needsReset = fam.length !== 2 || fam[0]?.relation !== 'mother' || fam[1]?.relation !== 'father' + + if (needsReset) { formRef.value.setFieldValue('families', [ { relation: 'mother', name: '', education: '', occupation: '' }, { relation: 'father', name: '', education: '', occupation: '' }, @@ -51,9 +52,7 @@ watch( isFamilyFormDisabled.value = true - if (!isEditing.value) { - formRef.value.setFieldValue('families', []) - } + formRef.value.setFieldValue('families', []) }, { immediate: true }, ) @@ -105,7 +104,7 @@ watch( class="space-y-4 rounded-lg border border-gray-200 bg-gray-50/50 p-4 dark:border-gray-700 dark:bg-gray-800/50" >

- {{ (values.families as FamilyData[])?.[idx]?.relation === 'mother' ? 'Data Ibu' : 'Data Ayah' }} + {{ (field.value as FamilyData).relation === 'mother' ? 'Data Ibu' : 'Data Ayah' }}