Closed andreCatita closed 9 years ago
@andreCatita Good idea, but if you want to delete all previously set values for the translation, the translation model will not be saved
echo $model->title_fr; // title fr
echo $model->body_fr; // body fr
$model->title = 'test title';
$model->body = 'test body';
$model->title_fr = '';
$model->body_fr = '';
$model->save();
$model = Post::findOne($model->id);
echo $model->title_fr; // title fr
echo $model->body_fr; // body fr
@OmgDef True.. You see any workaround?
I don't even think we can tell if we are updating or creating it the first time, seeing as it's Yii handling it.
@andreCatita I implemented this feature
@OmgDef Yeah, I had just managed to fix it myself, I however was still verifying with the (!empty()), coz' I didn't look into your getLangAttribute, but if you added your flag into the != null verification, it's because you've taken it into consideration.
Good job.
I found something new you could add to your ml behavior as a flag It's an enhancement if you wish to your 2.0 milestone, I added it to my project.
By default, the behavior saves all languages, even if all translated fields are empty. Since I don't want that, to avoid having meaningless rows in my case, I just added a quick verification:
in saveTranslations, before running through the attributes I declared:
Inside the for, I have:
And when it comes to save, I just check the flag: