Skip to content

Commit

Permalink
[TM-714] Update workdays as an entity relation.
Browse files Browse the repository at this point in the history
  • Loading branch information
roguenet committed Apr 16, 2024
1 parent 488dbb3 commit bf1fe4a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Models/Traits/UsesLinkedFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit bf1fe4a

Please sign in to comment.