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

After upgrading Yii to version 2.0.14 creating new translations not working #15

Open
kadarpeter opened this issue Mar 4, 2018 · 5 comments

Comments

@kadarpeter
Copy link

Before Yii version 2.0.14, the following code works well:

class PostController extends Controller
{
    public function actionCreate()
    {
        $model = new Post();

        foreach (Yii::$app->request->post('PostTranslation', []) as $language => $data) {
            foreach ($data as $attribute => $translation) {
                $model->translate($language)->$attribute = $translation;
            }
        }

        //...
    }

After upgrading Yii to version 2.0.14, the above code does not working. The related records in the post_translation table are not created. If I update the newly created post record, the translations are created in the post_translation table.

@greeflas
Copy link

greeflas commented Mar 4, 2018

Next algorithm works too

$template = new EmailTemplate();
$template->key = 'test';

$translation = $template->getTranslation('en');
$translation->subject = 'subject test';
$translation->body = 'body test';
$translation->hint = 'hint test';

$template->save();
$template->link('translations', $translation);

cc @kadarpeter

greeflas added a commit to greeflas/yii2-translateable that referenced this issue Mar 12, 2018
@greeflas
Copy link

@creocoder I created pull request with fix of this issue. Can you check it, please?

greeflas added a commit to greeflas/yii2-translateable that referenced this issue Mar 12, 2018
greeflas added a commit to greeflas/yii2-translateable that referenced this issue Mar 12, 2018
@greeflas
Copy link

greeflas commented Apr 22, 2018

Here is available supported new translatable behavior extension. Try it :)
https://github.com/yiimaker/yii2-translatable

cc @kadarpeter @alex2549

@alexanderYakovenkoUkr
Copy link

@greeflas Thank YOU A LOT! Cause I faced that problem today as well, so your https://github.com/yiimaker/yii2-translatable behavior save me.
Only one thing I ask you to add in your repo is instruction with migration example, that would help new users how to use it as well as it's done by @creocoder.

@greeflas
Copy link

greeflas commented Jul 4, 2018

@SanChes-tanker Yes, I can. Please create an issue for this.

akiraz2 added a commit to akiraz2/yii2-translateable that referenced this issue Sep 7, 2018
Fixes creocoder#15: Fixed saving translations
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

3 participants