Open Defcon0 opened 4 years ago
What version are you using? preventSaving got removed in the latest major version.
I have contao 4.4 and dc_multilingual 4.
The preventSaving is still in the master:
Don‘t let it irritate you. $this->preventSaving(false); leads to prevent the model from save.
We struggle with this problem on Contao 4.9 with Version 4, too :-(
Is there any simple workaround?
I guess we have to implement a solution like saveUntranslatedRecord
Gibt es hier schon Neuigkeiten?
Ich habe mir aktuell so in einer abstrakten Klasse beholfen (könnte man bei Mehrfachverwendung auch in einen Trait packen):
public function saveIfOriginal(): bool
{
if (0 !== (int)$this->langPid) {
return false;
}
$registry = Registry::getInstance();
if ($this->id && !$registry->isRegistered($this)) {
$registry->register($this);
}
$this->blnPreventSaving = false;
$this->save();
return true;
}
Hello,
we integrated DC_Multilingual in many projects now. It works just fine. Only one thing is quite a problem: the disallowing of saving (preventSaving) as described here.
I understand the problem (the record is merged from multiple records (the translations)).
Now I thought how we could solve this issue and one option would be to introduce a new method called
saveUntranslatedRecord()
. This method would work on the data retrieved from the database without taking into account the ranslations. InsaveUntranslatedRecord()
we would store the modified values merged with the untranslated values (retrieved from the database ignoring the translations) using anUPDATE
.I could also imagine that we wouldn't have to introduce a new
saveUntranslatedRecord()
but put this code intosave()
. Of course this would be BC breaking, but at the moment callingsave()
throws an error only.What do you think? I could also write a pull request if you agree that this would be a way to deal with the limitation of not being able to
save()
.Thanks in advance.
Bye Defcon0