Skip to content
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

Make JsonRepeaters translatable #971

Closed
antonioribeiro opened this issue Jun 11, 2021 · 2 comments
Closed

Make JsonRepeaters translatable #971

antonioribeiro opened this issue Jun 11, 2021 · 2 comments

Comments

@antonioribeiro
Copy link
Member

Summary

If you create a json repeater and make it translatable, Twill will save it correctly in all languages, but then it will not be able to load it back into the CMS frontend because the trait is not translation aware.

@antonioribeiro
Copy link
Member Author

It is translatable, but I was using it wrong, this is how you do it:

  • Create the JSON field on the main table, not the translations
  • Set the form fields as "translated" => true
  • Done! 😆

@LucaRed
Copy link
Contributor

LucaRed commented Nov 18, 2022

Thank you, you saved my life!

In case @antonioribeiro's solution is not clear enough:

  • JSON field goes on the main table (not the _translations one)
  • There's no need to specify the translation on the @formField('repeater') field (in the main form Blade view)
  • In the repeater Blade file, set 'translated' => true on the inputs you want to translate (you can translate some of them or all of them)
  • On the model, don't add the json field in the $translatedAttributes array
  • Add it however on both the $fillable and $casts arrays

This is the working solution on my current Twill version, which is 2.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants