From a08322a23a7d02e46a502912ad901cffedc9fa92 Mon Sep 17 00:00:00 2001 From: schroeder-hesel <107101263+schroeder-hesel@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:07:43 +0100 Subject: [PATCH] fix: properly strip Filament attribute prefixes for both resource forms and Relation Manager forms Previously, the getFilamentAttributeNameAndLocale() function only handled attributes prefixed with "data.", as used by Filament resource forms. In the Relation Manager context, however, attributes appear as "mountedTableActionsData.." (e.g. "mountedTableActionsData.0.slug"), which caused issues. This change updates the function to remove both "data." and "mountedTableActionsData.." prefixes via a regular expression before splitting off any locale part. It now correctly handles both Filament resource forms and Relation Manager attribute formats, ensuring the attribute name and (if present) the locale are parsed consistently. --- src/UniqueTranslationValidator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UniqueTranslationValidator.php b/src/UniqueTranslationValidator.php index c50c81e..c35c58a 100644 --- a/src/UniqueTranslationValidator.php +++ b/src/UniqueTranslationValidator.php @@ -101,7 +101,7 @@ protected function getNovaAttributeNameAndLocale($attribute) */ protected function isFilamentTranslation($attribute) { - return strpos($attribute, 'data.') === 0; + return Str::startsWith($attribute, ['data.', 'mountedTableActionsData.']); } /** @@ -113,7 +113,7 @@ protected function isFilamentTranslation($attribute) */ protected function getFilamentAttributeNameAndLocale($attribute, $validator) { - $attribute = str_replace('data.', '', $attribute); + $attribute = preg_replace('~^(?:data|mountedTableActionsData\.\d+)\.~', '', $attribute); $dataValidator = $validator->getData();