teppokoivula / VersionControl

Version Control Module For ProcessWire CMS/CMF
GNU General Public License v2.0
26 stars 10 forks source link

Multi-language textfields - database is not filled with the original values at module installation time #13

Open happy-kaseem opened 7 years ago

happy-kaseem commented 7 years ago

VersionControl does at the moment of its installation not store the initial values of TextareaLanguage (Textarea [Multi-language]) fields. To be specific probably all fields which store there data with the class LanguagesPageFieldValue. I have been testing it again on the latest release version 1.2.9 by installing VersionControl on my test site and activating it for two fields on one template. The two fields are of type:

                } else if ($data instanceof LanguagesPageFieldValue) {
                    foreach ($data->getChanges() as $key) {
                        if ($key == 'data') continue;
                        $data_array[$key] = $data->getLanguageValue(str_replace('data', '', $key));
                    }
                } else {

(see code on github here)

I have done some research on how the data is stored internally at run-time and on the database and I hope that my patch addresses the problem correctly: Every language value, including the default language, is stored under a key 'data'.$language->id, the same way the function getChanges() returns the keys.

I have made a suggestion for how to changes this on my fork. There is a pull request available.

teppokoivula commented 7 years ago

Thanks. I'll take a closer look at your PR soon!

tbba commented 6 years ago

True multilanguage support would be so great. Right now on a restore the content of one language is filled into both language areas, the correspondent language gets overwritten and lost.

teppokoivula commented 6 years ago

Thanks for the feedback, @tbba. Could this be related to the multi-language issue reported via forums?

https://processwire.com/talk/topic/6333-version-control/?do=findComment&comment=165018

Note: as far as I can tell, this is not related to the first post in this issue. This issue is about the module not pre-populating initial values for multi-language fields during installation.