From bf1fe4a0cff2b64cba28b4c21b240f24a9fc46a0 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Tue, 16 Apr 2024 15:27:27 -0700 Subject: [PATCH] [TM-714] Update workdays as an entity relation. --- app/Models/Traits/UsesLinkedFields.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Models/Traits/UsesLinkedFields.php b/app/Models/Traits/UsesLinkedFields.php index b35a07012..f04d4cb6d 100644 --- a/app/Models/Traits/UsesLinkedFields.php +++ b/app/Models/Traits/UsesLinkedFields.php @@ -77,7 +77,8 @@ public function updateFromForm(array $formData): void } else { $property = data_get($relationsConfig, "$question->linked_field_key.property"); if (! empty($property)) { - $this->syncRelation($property, collect(data_get($formData, $question->uuid))); + $inputType = data_get($relationsConfig, "$question->linked_field_key.input_type"); + $this->syncRelation($property, $inputType, collect(data_get($formData, $question->uuid))); } } @@ -242,10 +243,10 @@ private function updateLinkedFieldValue(array $linkedFieldInfo, $answer): void } } - private function syncRelation(string $property, $data): void + private function syncRelation(string $property, string $inputType, $data): void { // This will expand as we complete more tickets in TM-747, until eventually we support all form relations. - if ($property != 'treeSpecies') { + if (! in_array($inputType, ['treeSpecies', 'workdays'])) { return; }