-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Translations don't work since spatie-translatable v6.10.0 #5770
Comments
Based on the information provided in your bug report, it appears that there is indeed an incompatibility issue between the latest versions of Backpack and spatie/laravel-translatable (v6.10.0 and above). This issue is causing translations to not work properly in the Backpack admin panel. Let's break down the problem and the current workaround:
I recommend reporting this issue on the Backpack GitHub repository if you haven't already done so. This will alert the maintainers to the problem and hopefully lead to a fix in a future release. In the meantime, you can continue using the workaround of downgrading spatie/laravel-translatable to version 6.9.3 until an official fix is released. Backpack CRUD GitHub Issues is the best place to report this bug and track its progress. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Github Issue (closed): [Bug] Regression with auto casting and spatie/laravel-translation |
🔍 Issue ConfirmationI can confirm this issue. Spatie’s ✅ Temporary FixTo override this behavior, add the following method to your model: /* Debug Spatie and Backpack conflict */
public function initializeHasTranslations(): void
{
$this->mergeCasts(
array_fill_keys($this->getTranslatableAttributes(), 'string'),
);
} This forces translatable fields to be treated as strings instead of arrays. Looking forward to a resolution! 🚀 |
This is now fixed in Cheers |
Bug report
Since version v6.10.0 of spatie/laravel-translatable package - translations don't work in backpack. Version 6.10 in spatie-translatable package introduced auto casting all translatable fields to array:
spatie/laravel-translatable@6.9.3...6.10.0
in file src/HasTranslations.php there were following lines added:
And therefore,
decodeJsonCastedAttributes
method insidesrc/app/Library/CrudPanel/Traits/Input.php
file on line 216 strips the values from form when updating / creating records via Backpack admin panel.What I did
Installed newest version of backpack with newest version of spatie-translatable
What I expected to happen
Translations to work properly inside backpack admin panel
What happened
They didn't. The DB record is always udated with null value (
{"en": null}
for example)What I've already tried to fix it
Downgrading spatie/laravel-translatable to pre v6.10 version works as a temporary fix (v6.9.3 being latest before v6.10)
Is it a bug in the latest version of Backpack?
Yep
Backpack, Laravel, PHP, DB version
PHP VERSION:
8.3.15
PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, FFI, fileinfo, filter, ftp, gd, gettext, gmp, json, iconv, intl, SPL, ldap, mbstring, session, standard, odbc, pcntl, exif, mysqlnd, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, random, readline, Reflection, mysqli, shmop, SimpleXML, soap, sockets, sodium, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, redis, imagick, Zend OPcache
LARAVEL VERSION:
11.37.0.0
BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.51
backpack/generators: v4.0.7
backpack/pro: 2.2.32
backpack/theme-tabler: 1.2.17
Additional Information
Nothing special really, works as expected with older versions of spatie/laravel-translatable
The text was updated successfully, but these errors were encountered: