|
469 | 469 | </template>
|
470 | 470 | </Field>
|
471 | 471 |
|
472 |
| - <Field |
473 |
| - :label="$t('video_link_label')" |
474 |
| - alt |
475 |
| - :errors="formChangeStatus.errors.videos || arrayError('videos.0.url')" |
476 |
| - > |
| 472 | + <Field :label="$t('video_link_label')" alt :errors="formChangeStatus.errors.videos || arrayError('videos')"> |
477 | 473 | <template #value>
|
478 | 474 | <div class="flex items-center col-span-12 gap-6 text-base font-medium leading-6 text-gray-700">
|
479 | 475 | <div class="grid gap-4">
|
|
501 | 497 | {
|
502 | 498 | label: $t('video_link_label'),
|
503 | 499 | key: 'url',
|
504 |
| - error: arrayError('videos.0.url'), |
| 500 | + error: arrayError('videos'), |
505 | 501 | },
|
506 | 502 | ]"
|
507 |
| - :error="arrayError('videos.0.url')" |
| 503 | + :error="arrayError('videos')" |
508 | 504 | name="videos"
|
509 | 505 | />
|
510 | 506 | </EditModal>
|
|
513 | 509 |
|
514 | 510 | <Field
|
515 | 511 | :label="$t('external_links_title')"
|
516 |
| - :errors="formChangeStatus.errors.external_links || arrayError('external_links.0.title')" |
| 512 | + :errors="formChangeStatus.errors.external_links || arrayError('external_links')" |
517 | 513 | >
|
518 | 514 | <template #value>
|
519 | 515 | <div class="flex items-center col-span-12 gap-6 text-base font-medium leading-6 text-gray-700">
|
|
533 | 529 | <EditModal
|
534 | 530 | @action="editField('external_links')"
|
535 | 531 | class="flex justify-end col-span-1"
|
536 |
| - :errors="arrayError('external_links.0.url')" |
| 532 | + :errors="arrayError('external_links')" |
537 | 533 | :label="$t('external_links_title')"
|
538 | 534 | >
|
539 | 535 | <RepeaterComponent
|
|
543 | 539 | {
|
544 | 540 | label: $t('project.labels.external_links_title'),
|
545 | 541 | key: 'title',
|
546 |
| - error: arrayError('external_links.0.title'), |
| 542 | + error: arrayError('external_links'), |
547 | 543 | },
|
548 | 544 | {
|
549 | 545 | label: $t('project.labels.external_links_url'),
|
550 | 546 | key: 'url',
|
551 |
| - error: arrayError('external_links.0.url'), |
| 547 | + error: arrayError('external_links'), |
552 | 548 | },
|
553 | 549 | ]"
|
554 | 550 | />
|
@@ -650,9 +646,12 @@ const editField = (field) => {
|
650 | 646 | });
|
651 | 647 | };
|
652 | 648 | function arrayError(key) {
|
653 |
| - if (props?.errors[key]) { |
654 |
| - return props?.errors[key]; |
655 |
| - } |
656 |
| - return null; |
| 649 | + let errorMessage = ''; |
| 650 | + Object.keys(props?.errors).forEach((error) => { |
| 651 | + if (error.startsWith(key)) { |
| 652 | + errorMessage = props?.errors[error]; |
| 653 | + } |
| 654 | + }); |
| 655 | + return errorMessage; |
657 | 656 | }
|
658 | 657 | </script>
|
0 commit comments