wintercms / wn-translate-plugin

Translate plugin for Winter CMS
MIT License
13 stars 18 forks source link

datatable formwidget within a translatable repeater clears values on locale switch #33

Open der-On opened 2 years ago

der-On commented 2 years ago

If there is a datatable formwidget within a mlrepeater it does not send it's values over POST when switching locale.

The reason is that the table widget listens to a postback handler with the name onSave by default and only attaches the table values to the request if this ajax handler is used.

The solution is to temporary set the handler to the onSwitchItemLocale when the locale is beeing changed.

bennothommo commented 2 years ago

@der-On TBH, I would rather a fix that changes the Table widget to provide its data at all times, not just on a specific AJAX callback. The callback is more for tables that use server side data storage, essentially operating independently from the form. When the table is used normally (entirely client side), its data should be sent through the POST like any other field.

This particular change is probably a little too abstract and "hacky" to accept as it is.

der-On commented 2 years ago

@bennothommo No problem. Then I'll wait for the fix in the Table widget and use my fork until then. Will you provide the fix in the backend module or should I do a PR for that?

LukeTowers commented 2 years ago

@der-On if you could provide a PR for that then that would be the best way forward; we're currently very busy on a number of complex projects (Laravel 9 finalizations, static analysis, search plugin, tailwind UI skin, new website / marketplace, etc - all in addition to our regular day jobs) so the best we could do for you is provide code review on your requested changes.

der-On commented 2 years ago

@LukeTowers Sure no problem. Thank for your faith. Happy to help.

der-On commented 2 years ago

@bennothommo @LukeTowers Where exactly can I provide a PR for the backend module? The repository on github says it's a "read only mirror".

mjauvin commented 2 years ago

@der-On You need to clone winter/winter into your repo, then create a branch in your repo for this PR.

Once this is done, you need to create a PR from github to Winter's repo against your repo.

LukeTowers commented 2 years ago

@der-On the wintercms/winter repository.

der-On commented 2 years ago

@LukeTowers @bennothommo PR is now here: https://github.com/wintercms/winter/pull/560