-
Notifications
You must be signed in to change notification settings - Fork 86
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
Cast attributes are saved to db and to 'rainlab_translate_attributes'… #322
Cast attributes are saved to db and to 'rainlab_translate_attributes'… #322
Conversation
… but have empty value for default language in editor Model.php: public $translatable = ['title', 'fields[test11]', 'fields[test12]', 'fields[test21]']; protected $casts = [ 'fields' => 'array' ]; fields.yml: 'fields[test11]': label: Test11 type: text tab: 'Content' 'fields[test12]': label: Test12 type: text tab: 'Content' After saving data I have proper values in DB. I open this form for editing and switch to not default language, then back to default - and field becomes empty. I'm using latest october version. For other field types like Markdown it works same way.
Why Pull request has not yet merged? I have the same problem. |
@iboved because I haven't had time to review and test it thoroughly yet. If it's something you need then please test it locally and try as many different ways to break it as possible so that we can merge a solidly tested fix. |
@LukeTowers I can confirm the issue still exist. It's almost a year old, |
I haven't merged this in yet because I don't understand what this fix is doing and I don't have time to become acquainted enough with the issue myself to figure out how this fix works. If someone can break it down for me line by line as to how this fix works then I'd be happy to merge it in. |
Hi everyone, I've implemented a proof-of-concept with some explanations in the following repo for the fix in this PR: You should be able to run this pretty easily by reading my Cheers, |
I noticed by testing the stuff I did in the themes (I'm using the translated See the and I can fetch the translated |
I am starting to think that we should not be doing the Let me know if you guys have some input on this. |
Closing as it has been over a month since any activity on this occurred and we are trying to figure out what issues are still relevant. If this is still something that you would like to see through to fruition please respond and we can get the ball rolling. |
@osmanzeki first of all, thanks for the very nice and complete description of the issue. Would it be possible to do the json decoding here: With the proper conditions added (like check if the part without the index is in $jsonable or $casts property? i.e. meta[title] -> meta... is meta in $jsonable or $casts property, do the decoding) |
Something like this maybe (not tested):
|
Hey Marc, Sorry for the late reply, I have been out of the country for work for the last month or so, just came back to my senses here. :) I would need to immerse myself back into the problem to be sure for your question. I've added a reminder in my calendar to try to do that this week or the next one. That said, I think the problem here was that there was a few missing links between all the systems that the translation module interacts with and thus that trying to do the json decoding too late down the function execution order was leading to problems. I'm not sure if this location is early enough to alleviate the issues down the line. Especially when something is translatable but not a string/text like the image field, file field, another json like the Repeaters, etc. I think with more test coverage on the rainlab translate plugin we could be better suited to identify where the chain seems to break sometimes. |
Closing as it has been over a month since any activity on this occurred and we are trying to figure out what issues are still relevant. If this is still something that you would like to see through to fruition please respond and we can get the ball rolling. |
fix for #303 |
Closed in favor of simpler fix in #556 |
… but have empty value for default language in editor
Model.php:
public $translatable = ['title', 'fields[test11]', 'fields[test12]', 'fields[test21]'];
protected $casts = [
'fields' => 'array'
];
fields.yml:
After saving data I have proper values in DB. I open this form for editing and switch to not default language, then back to default - and field becomes empty.
I'm using latest october version. For other field types like Markdown it works same way.