Skip to content

Commit 35a117d

Browse files
committed
Give customf ields priority
1 parent d5657f9 commit 35a117d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Concerns/CanMapDynamicFields.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,20 @@ private function resolveCustomFields(): Collection
141141

142142
private function resolveFieldInput(Model $field, Collection $customFields, mixed $record = null, bool $isNested = false): ?object
143143
{
144-
$record = $record ?? $this->record;
144+
$record = $record ?? $this->record;
145145

146146
$inputName = $isNested ? "{$field->ulid}" : "{$record->valueColumn}.{$field->ulid}";
147147

148-
// Try to resolve from standard field type map
149-
if ($fieldClass = self::FIELD_TYPE_MAP[$field->field_type] ?? null) {
150-
return $fieldClass::make(name: $inputName, field: $field);
151-
}
152-
153-
// Try to resolve from custom fields
148+
// Try to resolve from custom fields first (giving them priority)
154149
if ($customField = $customFields->get($field->field_type)) {
155150
return $customField::make($inputName, $field);
156151
}
157152

153+
// Fall back to standard field type map if no custom field found
154+
if ($fieldClass = self::FIELD_TYPE_MAP[$field->field_type] ?? null) {
155+
return $fieldClass::make(name: $inputName, field: $field);
156+
}
157+
158158
return null;
159159
}
160160
}

0 commit comments

Comments
 (0)