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

How to delete a translation of a nullable fields? #88

Open
matperez opened this issue Nov 24, 2020 · 0 comments
Open

How to delete a translation of a nullable fields? #88

matperez opened this issue Nov 24, 2020 · 0 comments

Comments

@matperez
Copy link
Contributor

Hello!

Thank you for behavior, it saved me a lot of time! Now I have an issue. I used it in my model

                'class' => MultilingualBehavior::class,
                'languages' => [
                    'ru' => 'Russian',
                    'en-En' => 'English',
                ],
                'defaultLanguage' => 'ru',
                'langForeignKey' => 'counterparty_id',
                'tableName' => '{{%counterpartyLang}}',
                'attributes' => [
                    'message',
                ]

Everything seems to work fine except of one thing. I can not delete the value of message field in english. I can only set it to a different value, not no null. According to the source code it is the intended behavior, you only update the field if it's not null.

                if ($value !== null) {
                    $field = $this->localizedPrefix . $attribute;
                    $translation->$field = $value;
                    $save = true;
                }

So how can I delete an existing translation? How to cope with a nullable fields?

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

1 participant