orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.44k stars 655 forks source link

Translatable fields in Form Screens not populating existing values #2923

Open macit-emre opened 1 week ago

macit-emre commented 1 week ago

i am using spatie/laravel-translatable with json fields in translation.

afer upgrading from 14.38.0 to 14.43.1, Tables with TD::make('title.tr', ('Title')) needs to be TD::make('title', ('Title')), that can be done by find and replace no problem.

But in form screens, Input::make('paymentGateway.name.'.$locale) is now cannot populate existing tr,en,etc.. translation of the name field. That will be a lot of massive code refactor (because of dynamically adding new languages), and thus cannot be done by design.

macit-emre commented 1 week ago

this is because of : https://github.com/orchidsoftware/platform/pull/2921/commits/e13b5d31e6463ae98f78e4cd3e78a68235de83bd

macit-emre commented 1 week ago

Should i use AsMultiSource instead of AsSource?

macit-emre commented 1 week ago

nope, it has only 1 json field. I Have to override AsSource. Wish me luck if there will not be any class_uses_recursive usage of this class.

tabuna commented 5 days ago

If I understand things correctly, after making some changes to improve performance, the fields with cast to json/array stopped working.

This wasn't something we anticipated, but I don't want to break compatibility. My plan is to either roll back the changes or find a way to keep dot notation support for those fields. I'll also make sure to write a test for it.

If you have some time and are up for helping out, I'd really appreciate it!

macit-emre commented 5 days ago

You did improved the performance for sure. But spatie/translatable are not provided by array. They are being used by ->attribute so i implemented the old AsSource in my App/Traits directory and used them in my models instead of orchid's, nothing broken for now.

There is nothing to do for now i think. You may only maintain old "AsSource" or give the new one name as "AsSourceFromArray" or sth.

i dont see any other option here.

I appreciate to help, but no need i think.