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

Feature Request: Allow saving #62

Open
Defcon0 opened this issue Mar 11, 2020 · 4 comments
Open

Feature Request: Allow saving #62

Defcon0 opened this issue Mar 11, 2020 · 4 comments

Comments

@Defcon0
Copy link

Defcon0 commented Mar 11, 2020

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. In saveUntranslatedRecord() we would store the modified values merged with the untranslated values (retrieved from the database ignoring the translations) using an UPDATE.

I could also imagine that we wouldn't have to introduce a new saveUntranslatedRecord() but put this code into save(). Of course this would be BC breaking, but at the moment calling save() 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

@richardhj
Copy link
Member

What version are you using? preventSaving got removed in the latest major version.

@Defcon0
Copy link
Author

Defcon0 commented Mar 11, 2020

I have contao 4.4 and dc_multilingual 4.

The preventSaving is still in the master:

$model->preventSaving(false);

Don‘t let it irritate you. $this->preventSaving(false); leads to prevent the model from save.

@rabauss
Copy link
Contributor

rabauss commented Oct 26, 2020

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

@koertho
Copy link

koertho commented Dec 19, 2022

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;
}

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

4 participants