filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
17.41k stars 2.73k forks source link

Repeater with Spatie Translatable plugin doesnt cast objects #11826

Closed demianottema closed 4 months ago

demianottema commented 5 months ago

Package

filament/spatie-laravel-translatable-plugin

Package Version

v3.2.42

Laravel Version

v11.0

Livewire Version

v3.4.6

PHP Version

v8.2.4

Problem description

When i add a Repeater field in my (edit) resource page, all translations don't work and get replaced with: [object Object] When i dump the initial state using some code like this: TextInput::make("short_title")->afterStateHydrated(function (TextInput $component, string $state) { dump($state); }) The text is correct. That makes me think the page gets reloaded by a Repeater, maybe to fill its data? Besides that the repeater creates like 20 empty fields, also strange behaviour.

Something to mention is that i have a table with products and product_variants. The product_variants model is Translatable, but does't have its own page. Maybe it has any effect.

There are some other issues that have the simular problem. (#11175) But none have this behaviour. image

Expected behavior

I expected that the text is in the correct language

Steps to reproduce

Migrate the database, and check the page called Producten, when you click one you see the problem. This is my current project, but this was the first resource that i created.

Reproduction repository

https://github.com/demianottema/TG_Dashboard-V3

Relevant log output

No response

github-actions[bot] commented 5 months ago

Hey @demianottema! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.

github-actions[bot] commented 5 months ago

Thank you for providing reproduction steps! Reopening the issue now.

demianottema commented 5 months ago

@danharrin, What kind of help do you want? Or dont you expect help from me?

danharrin commented 5 months ago

Anyone can help by submitting or testing PRs. I've spent so much time on this plugin and its very difficult to balance the behaviour without breaking something else for someone, and there are other parts of the project that need my attention.

bahramzade commented 5 months ago
dmitry-udod commented 4 months ago

The reproduction repo is no longer accessible. @demianottema Can you update the URL, please?

Screenshot from 2024-04-12 10-20-41

devcbash commented 3 months ago

any news regarding this? for using the plugin with repeaters? and if not what can be a quick fix to get the json returned correctly in a textinput??

danharrin commented 3 months ago

I am posting this same message across all Spatie Translatable issues & PRs

Hey all! Wanted to update you on where we're at with the translatable plugin.

I really appreciate your patience while this issue has been active. While I created the plugin for the community, I've never actually had a project where I needed to use it, and that's the same for the rest of the Filament team. As such, it's the reason why the plugin hasn't had as much attention as the others, and is much more unstable: I just don't have the environment to test all the use cases, nor the motivation to make it truly great.

As such, I put out a post a month ago and asked who in the community uses the plugin and has knowledge of plugin development. Luckily, Lara Zeus and Mohamed Sabil stepped forward, who are both authors of popular Filament plugins and are trusted by the community.

We are strongly considering handing over maintenance of the plugin to those developers, for the good of the community. You can find their fork at https://github.com/lara-zeus/translatable.

Since the new developers have lots of experience with the plugin and active projects that use it, they should be able to help debug issues easier and make a much more stable experience for other users.

If their work goes well until v4 is released, we will likely retire the plugin at that point and recommend the fork as an official replacement. If it does not go as expected and the community is unhappy, then we will reconsider this decision. I am closing this for now, and if we decide to take maintenance back officially then we will probably reopen it.

The existing plugin will continue to receive security updates indefinitely. Please let me know if you have any further questions.

Many thanks, Dan

Khant-Nyar commented 2 months ago

in the model you need to cast as array protected $casts = [ 'short_title'=>'array'];