Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Translations for Userform


Go to End


1531 Views

Avatar
ragunalth

Community Member, 14 Posts

21 May 2010 at 7:47pm

Here is code to copy the form when creating a new language.

Add the following function in userforms/code/UserDefinedForm.php

        function createTranslation($locale) {
                $page = parent::createTranslation($locale);

                $newPage = $page->getTranslation(Translatable::default_locale());
                foreach($newPage->Fields() as $field) {
                           $newField = $field->duplicate();
                           $newField->ParentID = $page->ID;
                           $newField->write();
                }
                foreach($newPage->EmailRecipients() as $recipient) {
                           $newER = $recipient->duplicate();
                           $newER->FormID = $page->ID;
                           $newER->write();
                }

                return $page;
        }

After this has been added you can create new languages on a page and it should copy your form over.