Closed anaseqal closed 10 months ago
Having the same issue.
Same here
One more here. Stuck for hours to figure it out. :/
Same here
Same issue
Figured out the issue, not sure of how to resolve it though, @danharrin leaving this here for you to see what I'm seeing.
The issue is in the Translatable Plugin at Resources\Pages\EditRecord\Concerns\Translatable class.
When looping through the locales to save the record data is getting out of sync.
data in save()
for 'en' loop:
record in handleRecordUpdate()
:
All good to this point.
data in save()
for 'es' loop:
record in handleRecordUpdate()
:
Which means that when the 'es' handle record runs the 'media' state is [], which causes the FileUpload Plugin to delete the originally saved media item, resulting in it not existing when the state is refreshed after save.
@awcodes I reached similar thing and didnt know were to go from there I think it needed something like this to mearg the data https://github.com/filamentphp/filament/pull/7503/files
but the getState
in the edit is not getting the relations (it merges the data for all local if it's not relation like spatie uploader) so I don't know where to handle the "merge" for the data
The issue is that non translated fields don't seem to be honoring their state separately. Somehow the media field, in this example, is existing in two different states. One for each locale.
You can see that the es loop is getting updated with the origin values of the en loop but it's like it always a step behind.
same issue
same issue
Please stop commenting if you have the "same issue", there are 👍 reactions for that. Try submitting a PR if you would like to be helpful.
To clarify the original problem description, this appears to also happen when the image field itself is not translatable. It is enough for the field to be inside a resource that HasTranslations
(which I'd argue makes it a bit higher priority than "low").
Only workaround I can see at this point (for anyone under pressure to use spatie-translatable but also this field type RIGHT NOW) is to have a separate, my_media
table and resource, upload the images there, and connect them to the original resource using a relationship.
And somehow when you add some validation to FileUpload such as image() etc.. its showing error but saving eventually.
I had a very similar issue (it gave me an error when trying to get the file_size). Can you try if https://github.com/filamentphp/filament/pull/8432 solves the issue for you too?
This issue still occurred as @awcodes explained above. The #8432 seems doesn't fix it, or does it need extra steps @robertorinaldi-dev?
[
'en' => [
'id' => 8,
'position' => 5,
'description' => '',
'url' => '',
'order_column' => 8,
'created_at' => '2023-05-29T07:52:50.000000Z',
'updated_at' => '2023-05-29T07:52:50.000000Z',
'deleted_at' => null,
'image' => [],,
],
'ar' => [
'id' => 8,
'position' => 5,
'description' => '',
'url' => '',
'order_column' => 8,
'created_at' => '2023-05-29T07:52:50.000000Z',
'updated_at' => '2023-05-29T07:52:50.000000Z',
'deleted_at' => null,
'image' => [],,
],
]
@robertorinaldi-dev, the #8432 seems doesn't fix it. It still occurred, as @awcodes explained above. Do you think it needs any extra steps?
[
'en' => [
'id' => 8,
'position' => 5,
'description' => '',
'url' => '',
'order_column' => 8,
'created_at' => '2023-05-29T07:52:50.000000Z',
'updated_at' => '2023-05-29T07:52:50.000000Z',
'deleted_at' => null,
'image' => [],
],
'ar' => [
'id' => 8,
'position' => 5,
'description' => '',
'url' => '',
'order_column' => 8,
'created_at' => '2023-05-29T07:52:50.000000Z',
'updated_at' => '2023-05-29T07:52:50.000000Z',
'deleted_at' => null,
'image' => [],
],
]
[!IMPORTANT] This happened in one of my projects using stancl/tenancy. For those who used that package, it happened on the tenant's site, not the central one. It may be related to changes in Livewire 3.
Does not seem to be an issue any more, I've tried the reproduction repo.
Package
filament/spatie-laravel-translatable-plugin
Package Version
v3.0.13
Laravel Version
v10.18.0
Livewire Version
v3.0.0-beta.8
PHP Version
PHP 8.2.8
Problem description
Editing translatable resource image throw exception:
Even if no conversion defined, there is still an error:
Expected behavior
Edit image(s) without throwing errors
Steps to reproduce
Reproduction repository
https://github.com/anaseqal/filament3-media-translation
Relevant log output
No response